/
index.ts
55 lines (49 loc) 路 1.67 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Route } from '@/types';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import path from 'node:path';
export const route: Route = {
name: '鐑偣',
maintainers: ['nczitzk'],
example: '/houxu',
path: '/',
radar: [
{
source: ['houxu.app/'],
},
],
handler,
url: 'houxu.app/',
};
async function handler(ctx) {
const rootUrl = 'https://houxu.app';
const apiUrl = `${rootUrl}/api/1/records/index?limit=${ctx.req.query('limit') ?? 50}`;
const response = await got({
method: 'get',
url: apiUrl,
});
const items = response.data.results.map((item) => ({
guid: `${rootUrl}/lives/${item.object.id}#${item.object.last.id}`,
title: item.object.title,
link: `${rootUrl}/lives/${item.object.id}`,
author: item.object.last.link.source ?? item.object.last.link.media.name,
pubDate: parseDate(item.object.news_update_at),
description: art(path.join(__dirname, 'templates/lives.art'), {
title: item.object.title,
description: item.object.summary,
url: item.object.last.link.url,
linkTitle: item.object.last.link.title,
source: item.object.last.link.source ?? item.object.last.link.media.name,
content: item.object.last.link.description.replaceAll('\r\n', '<br>'),
pubDate: item.object.news_update_at,
}),
}));
return {
title: '鍚庣画 - 鐑偣',
link: rootUrl,
item: items,
};
}