UNPKG

rsshub

Version:
39 lines (38 loc) 1.3 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { n as rootUrl, t as ProcessFeed } from "./utils-YzhYnVS9.mjs"; import { load } from "cheerio"; //#region lib/routes/p-articles/contributors.ts const route = { path: "/contributors/:author", categories: ["reading"], example: "/p-articles/contributors/黃衍仁", parameters: { author: "虛詞作者, 可在作者页面 URL 找到" }, name: "虛詞作者", maintainers: ["Insomnia1437"], handler, radar: [{ source: ["p-articles.com/contributors/:author"] }] }; async function handler(ctx) { const authorName = ctx.req.param("author"); const authorUrl = new URL(`/contributors/${authorName}`, rootUrl).href; const response = await rofetch(authorUrl); const $ = load(response); const list = $("div.contect_box_05in > a").toArray().map((element) => { return { title: $(element).find("h3").text(), link: new URL($(element).attr("href"), rootUrl).href }; }); return { title: "虚词 p-articles", link: authorUrl, item: await Promise.all(list.map((info) => cache_default.tryGet(info.link, async () => { const response = await rofetch(info.link); return ProcessFeed(info, response); }))), language: "zh-CN" }; } //#endregion export { route };