جميع المصادر
Lobsters
المطورون v1.0.0Hottest stories from Lobsters
@codytseng #news #tech #programming
الإعدادات
| الاسم | المفتاح | النوع | مطلوب | القيمة الافتراضية | الوصف |
|---|---|---|---|---|---|
| Tag | TAG | string | لا | — | Filter by tag, comma-separated for multiple (e.g., programming,security,linux). Leave empty for all tags. |
الشيفرة المصدرية
version: 1.0.0
name: Lobsters
description: Hottest stories from Lobsters
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
- news
- tech
- programming
config:
- key: TAG
name: Tag
type: string
required: false
description: Filter by tag, comma-separated for multiple (e.g., programming,security,linux). Leave empty for all tags. version: 1.0.0
name: Lobsters
description: Hottest stories from Lobsters
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
- news
- tech
- programming
config:
- key: TAG
name: Tag
type: string
required: false
description: Filter by tag, comma-separated for multiple (e.g., programming,security,linux). Leave empty for all tags. import type { GlancewayAPI, SourceMethods } from "../../types";
export default (api: GlancewayAPI): SourceMethods => {
return {
async refresh() {
const tagConfig = api.config.get("TAG");
const url = tagConfig
? `https://lobste.rs/t/${tagConfig.split(",").map((t) => t.trim()).filter(Boolean).join(",")}.json`
: "https://lobste.rs/hottest.json";
const response = await api.fetch<
Array<{
short_id: string;
title: string;
url: string;
comments_url: string;
score: number;
comment_count: number;
tags: string[];
submitter_user: { username: string };
created_at: string;
}>
>(url);
if (!response.ok || !response.json) {
return;
}
api.emit(
response.json.slice(0, 30).map((story) => ({
id: story.short_id,
title: story.title,
subtitle: story.description || `${story.score} points · ${story.comment_count} comments · ${story.tags.join(", ")}`,
url: story.url || story.comments_url,
timestamp: story.created_at,
})),
);
},
};
}; import type { GlancewayAPI, SourceMethods } from "../../types";
export default (api: GlancewayAPI): SourceMethods => {
return {
async refresh() {
const tagConfig = api.config.get("TAG");
const url = tagConfig
? `https://lobste.rs/t/${tagConfig.split(",").map((t) => t.trim()).filter(Boolean).join(",")}.json`
: "https://lobste.rs/hottest.json";
const response = await api.fetch<
Array<{
short_id: string;
title: string;
url: string;
comments_url: string;
score: number;
comment_count: number;
tags: string[];
submitter_user: { username: string };
created_at: string;
}>
>(url);
if (!response.ok || !response.json) {
return;
}
api.emit(
response.json.slice(0, 30).map((story) => ({
id: story.short_id,
title: story.title,
subtitle: story.description || `${story.score} points · ${story.comment_count} comments · ${story.tags.join(", ")}`,
url: story.url || story.comments_url,
timestamp: story.created_at,
})),
);
},
};
};