* fix: allow multiple radar rules per route * fix: github folder * feat: add namespace to radar target * docs: fix types url
37 lines
869 B
TypeScript
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,
|
|
};
|
|
}
|