From 69994a1e27711b8efe83bd98f2ab1323d9988620 Mon Sep 17 00:00:00 2001 From: mocusez Date: Tue, 22 Oct 2024 07:31:25 +1100 Subject: [PATCH] feat(route): Add SYCL.tech (#17223) * feat(route): Add SYCL.tech * refactor(route): Change SYCL.tech namespace to SYCL * refactor(route): Update SYCL.tech namespace to SYCL - Change Descritption language from Chinese to English. - Format the description --- lib/routes/sycl/feeds.ts | 47 ++++++++++++++++++++++++++++++++++++ lib/routes/sycl/namespace.ts | 6 +++++ 2 files changed, 53 insertions(+) create mode 100644 lib/routes/sycl/feeds.ts create mode 100644 lib/routes/sycl/namespace.ts diff --git a/lib/routes/sycl/feeds.ts b/lib/routes/sycl/feeds.ts new file mode 100644 index 00000000000000..d7896ace7c0fa3 --- /dev/null +++ b/lib/routes/sycl/feeds.ts @@ -0,0 +1,47 @@ +import { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import { parseDate } from '@/utils/parse-date'; + +export const route: Route = { + path: '/:feed?', + categories: ['programming'], + example: '/sycltech/news', + parameters: { feed: 'Feed source, defaults to news, references https://feeds.sycl.tech/' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + name: 'Feeds', + maintainers: ['mocusez'], + handler, + description: `| Events | News | Research Paper | Videos | +| :----: | :--: | :-------------: | :----: | +| events | news | research_papers | videos |`, +}; + +async function handler(ctx) { + const feeds: string[] = ['news', 'events', 'research_papers', 'videos']; + let { feed = 'news' } = ctx.req.param(); + if (!feeds.includes(feed)) { + feed = 'news'; + } + const data = await ofetch(`https://feeds.sycl.tech/${feed}/feed.json`); + + const items = data.items.map((item) => ({ + title: item.title, + link: item.external_url, + description: item.content_html, + pubDate: parseDate(item.date_published), + author: item.author.name, + })); + + return { + title: `SYCL.tech ${feed}`, + link: `https://feeds.sycl.tech/${feed}/feed.json`, + item: items, + }; +} diff --git a/lib/routes/sycl/namespace.ts b/lib/routes/sycl/namespace.ts new file mode 100644 index 00000000000000..cefbb7fba34337 --- /dev/null +++ b/lib/routes/sycl/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'SYCL', + url: 'sycl.tech', +};