diff --git a/public/icons/openai.png b/public/icons/openai.png new file mode 100644 index 000000000..0b6b8a6c8 Binary files /dev/null and b/public/icons/openai.png differ diff --git a/server/glob.d.ts b/server/glob.d.ts index f3529fd13..198e6026f 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -27,6 +27,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const linuxdo: typeof import('./sources/linuxdo') export const mktnews: typeof import('./sources/mktnews') export const nowcoder: typeof import('./sources/nowcoder') + export const openai: typeof import('./sources/openai') export const pcbeta: typeof import('./sources/pcbeta') export const producthunt: typeof import('./sources/producthunt') export const qqvideo: typeof import('./sources/qqvideo') diff --git a/server/sources/openai.ts b/server/sources/openai.ts new file mode 100644 index 000000000..b8f585250 --- /dev/null +++ b/server/sources/openai.ts @@ -0,0 +1,21 @@ +import type { NewsItem } from "@shared/types" + +export default defineSource(async () => { + const rss = await rss2json("https://openai.com/blog/rss.xml") + if (!rss) return [] + + const news: NewsItem[] = [] + for (const item of rss.items) { + news.push({ + id: item.id, + title: item.title, + url: item.link, + extra: { + date: item.created, + hover: item.description, + }, + }) + } + + return news +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index d1d445523..862e1d092 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -28,6 +28,7 @@ "fastbull-news": "fabucaijing-toutiao", "solidot": "Solidot", "hackernews": "Hacker News", + "openai": "OpenAI", "producthunt": "Product Hunt", "github-trending-today": "Github-Today", "bilibili-hot-search": "bilibili-resou", diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index 7e519d424..1336b8aab 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -258,6 +258,14 @@ export const originSources = { type: "hottest", home: "https://news.ycombinator.com/", }, + "openai": { + name: "OpenAI", + color: "green", + column: "tech", + type: "realtime", + interval: Time.Common, + home: "https://openai.com/", + }, "producthunt": { name: "Product Hunt", color: "red", diff --git a/shared/sources.json b/shared/sources.json index 4cd566438..fc8fe91cc 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -322,6 +322,14 @@ "color": "orange", "interval": 600000 }, + "openai": { + "name": "OpenAI", + "type": "realtime", + "column": "tech", + "home": "https://openai.com/", + "color": "green", + "interval": 1800000 + }, "producthunt": { "name": "Product Hunt", "type": "hottest", diff --git a/wrangler.toml b/wrangler.toml new file mode 100644 index 000000000..5f20b3b27 --- /dev/null +++ b/wrangler.toml @@ -0,0 +1,8 @@ +name = "newsnow" +pages_build_output_dir = "dist/output/public" +compatibility_date = "2024-10-03" + +[[d1_databases]] +binding = "NEWSNOW_DB" +database_name = "newsnow-db" +database_id = ""