rsshub
Version:
Make RSS Great Again!
64 lines (61 loc) • 2.91 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/github/topic.ts
const route = {
path: "/topics/:name/:qs?",
categories: ["programming"],
example: "/github/topics/framework",
parameters: {
name: "Topic name, which can be found in the URL of the corresponding [Topics Page](https://github.com/topics/framework)",
qs: "Query string, like `l=php&o=desc&s=stars`. Details listed as follows:"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["github.com/topics"] }],
name: "Topics",
maintainers: ["queensferryme"],
handler,
url: "github.com/topics",
description: `| Parameter | Description | Values |
| --------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| \`l\` | Language | For instance \`php\`, which can be found in the URL of the corresponding [Topics page](https://github.com/topics/framework?l=php) |
| \`o\` | Sorting Order | \`asc\`, \`desc\` |
| \`s\` | Sorting Criteria | \`stars\`, \`forks\`, \`updated\` |
For instance, the \`/github/topics/framework/l=php&o=desc&s=stars\` route will generate the RSS feed corresponding to this [page](https://github.com/topics/framework?l=php\&o=desc\&s=stars).`
};
async function handler(ctx) {
const { data, url } = await got_default(`https://github.com/topics/${ctx.req.param("name")}`, { searchParams: new URLSearchParams(ctx.req.param("qs")) });
const $ = load(data);
return {
title: $("title").text(),
description: $(".markdown-body").text().trim(),
link: url,
item: $("article.my-4").toArray().map((item) => {
item = $(item);
const title = item.find("h3").text().trim();
return {
title,
author: title.split("/")[0],
description: (item.find("a img").prop("outerHTML") ?? "") + item.find("div > div > p").text(),
link: `https://github.com${item.find("h3 a").last().attr("href")}`,
category: item.find(".topic-tag").toArray().map((item$1) => $(item$1).text().trim()),
pubDate: parseDate(item.find("relative-time").attr("datetime"))
};
})
};
}
//#endregion
export { route };