diff --git a/public/icons/linuxdo.png b/public/icons/linuxdo.png new file mode 100644 index 0000000..838c74e Binary files /dev/null and b/public/icons/linuxdo.png differ diff --git a/scripts/favicon.ts b/scripts/favicon.ts index 3eb4e05..6911aa0 100644 --- a/scripts/favicon.ts +++ b/scripts/favicon.ts @@ -3,7 +3,6 @@ import fs from "node:fs" import { fileURLToPath } from "node:url" import { join } from "node:path" import { Buffer } from "node:buffer" -import { getLogos } from "favicons-scraper" import { consola } from "consola" import { originSources } from "../shared/sources" @@ -34,10 +33,7 @@ async function main() { return } if (!source.home) return - const res = await getLogos(source.home) - if (res.length) { - await downloadImage(res[0].src, icon, id) - } + await downloadImage(`https://icons.duckduckgo.com/ip3/${source.home.replace(/^https?:\/\//, "").replace(/\/$/, "")}.ico`, icon, id) } catch (e) { consola.error(id, "\n", e) } diff --git a/server/glob.d.ts b/server/glob.d.ts index 9ccdbb2..87779e6 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -16,6 +16,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const jin10: typeof import('./sources/jin10') export const kaopu: typeof import('./sources/kaopu') export const kuaishou: typeof import('./sources/kuaishou') + export const linuxdo: typeof import('./sources/linuxdo') export const producthunt: typeof import('./sources/producthunt') export const solidot: typeof import('./sources/solidot') export const sputniknewscn: typeof import('./sources/sputniknewscn') diff --git a/server/sources/linuxdo.ts b/server/sources/linuxdo.ts new file mode 100644 index 0000000..ec92864 --- /dev/null +++ b/server/sources/linuxdo.ts @@ -0,0 +1,61 @@ +interface Res { + topic_list: { + can_create_topic: boolean + more_topics_url: string + per_page: number + top_tags: string[] + topics: { + id: number + title: string + fancy_title: string + posts_count: number + reply_count: number + highest_post_number: number + image_url: null | string + created_at: Date + last_posted_at: Date + bumped: boolean + bumped_at: Date + unseen: boolean + pinned: boolean + excerpt?: string + visible: boolean + closed: boolean + archived: boolean + like_count: number + has_summary: boolean + last_poster_username: string + category_id: number + pinned_globally: boolean + }[] + } +} + +const hot = defineSource(async () => { + const res = await myFetch("https://linux.do/top/daily.json") + return res.topic_list.topics + .filter(k => k.visible && !k.archived && !k.pinned) + .map(k => ({ + id: k.id, + title: k.title, + url: `https://linux.do/t/topic/${k.id}`, + })) +}) + +const latest = defineSource(async () => { + const res = await myFetch("https://linux.do/latest.json?order=created") + return res.topic_list.topics + .filter(k => k.visible && !k.archived && !k.pinned) + .map(k => ({ + id: k.id, + title: k.title, + pubDate: new Date(k.created_at).valueOf(), + url: `https://linux.do/t/topic/${k.id}`, + })) +}) + +export default defineSource({ + "linuxdo": latest, + "linuxdo-latest": latest, + "linuxdo-hot": hot, +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index 5683474..3c3c750 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -27,5 +27,7 @@ "bilibili-hot-search": "bilibili-resou", "kaopu": "kaopuxinwen", "jin10": "jinshishuju", - "baidu": "baiduresou" + "baidu": "baiduresou", + "linuxdo-latest": "Linux DO-zuixin", + "linuxdo-hot": "Linux DO-remen" } diff --git a/shared/sources.ts b/shared/sources.ts index d32d5dd..ea8b6f9 100644 --- a/shared/sources.ts +++ b/shared/sources.ts @@ -282,6 +282,24 @@ export const originSources = { type: "hottest", home: "https://www.baidu.com", }, + "linuxdo": { + name: "LINUX DO", + column: "tech", + color: "slate", + home: "https://linux.do/", + sub: { + latest: { + title: "最新", + home: "https://linux.do/latest", + }, + hot: { + title: "今日最热", + type: "hottest", + interval: Time.Common, + home: "https://linux.do/hot", + }, + }, + }, } as const satisfies Record export const sources = genSources()