Skip to content

Commit

Permalink
feat(route): Add SYCL.tech (#17223)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mocusez authored Oct 21, 2024
1 parent 58e61cc commit 69994a1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
47 changes: 47 additions & 0 deletions lib/routes/sycl/feeds.ts
Original file line number Diff line number Diff line change
@@ -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,
};
}
6 changes: 6 additions & 0 deletions lib/routes/sycl/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'SYCL',
url: 'sycl.tech',
};

0 comments on commit 69994a1

Please sign in to comment.