MCPcopy Create free account
hub / github.com/DIYgod/RSSHub / handler

Function handler

lib/routes/github/topic.ts:38–74  ·  view source on GitHub ↗
(ctx)

Source from the content-addressed store, hash-verified

36};
37
38async function handler(ctx) {
39 const link = `https://github.com/topics/${ctx.req.param('name')}`;
40 const { data, url } = await got(link, {
41 searchParams: new URLSearchParams(ctx.req.param('qs')),
42 });
43 const $ = load(data);
44
45 return {
46 title: $('title').text(),
47 description: $('.markdown-body').text().trim(),
48 link: url,
49 item: $('article.border')
50 .toArray()
51 .map((item) => {
52 item = $(item);
53
54 const title = item.find('h3').text().trim();
55 const author = title.split('/', 1)[0];
56 const description = (item.find('a img').prop('outerHTML') ?? '') + item.find('div > div > p').text();
57 const link = `https://github.com${item.find('h3 a').last().attr('href')}`;
58 const category = item
59 .find('.topic-tag')
60 .toArray()
61 .map((item) => $(item).text().trim());
62 const pubDate = parseDate(item.find('relative-time').attr('datetime'));
63
64 return {
65 title,
66 author,
67 description,
68 link,
69 category,
70 pubDate,
71 };
72 }),
73 };
74}

Callers

nothing calls this directly

Calls 3

parseDateFunction · 0.90
$Function · 0.85
loadFunction · 0.50

Tested by

no test coverage detected