Files
RSSHub/lib/routes/hk01/issue.ts
T
Tony d585a87daf fix: allow multiple radar rules per route (#14800)
* fix: allow multiple radar rules per route

* fix: github folder

* feat: add namespace to radar target

* docs: fix types url
2024-03-16 03:28:44 +08:00

37 lines
869 B
TypeScript

import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { rootUrl, apiRootUrl, ProcessItems } from './utils';
export const route: Route = {
path: '/issue/:id?',
radar: [
{
source: ['hk01.com/issue/:id', 'hk01.com/'],
},
],
name: 'Unknown',
maintainers: [],
handler,
};
async function handler(ctx) {
const id = ctx.req.param('id') ?? '649';
const currentUrl = `${rootUrl}/issue/${id}`;
const apiUrl = `${apiRootUrl}/v2/issues/${id}`;
const response = await got({
method: 'get',
url: apiUrl,
});
const items = await ProcessItems(response.data.blocks[0].articles, ctx.req.query('limit'), cache.tryGet);
return {
title: `${response.data.title} | 香港01`,
link: currentUrl,
item: items,
};
}