UNPKG

rsshub

Version:
55 lines (53 loc) 1.66 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { load } from "cheerio"; //#region lib/routes/qwenlm/blog.ts const route = { path: "/blog/:lang?", categories: ["blog"], example: "/qwenlm/blog/zh", parameters: { lang: "Blog language" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["qwenlm.github.io/blog/", "qwenlm.github.io/:lang/blog/"], target: "/qwenlm/blog/:lang" }], name: "Blog", maintainers: ["Kjasn"], handler: async (ctx) => { const { lang } = ctx.req.param(); const blogUrl = lang ? `https://qwenlm.github.io/${lang}/blog` : "https://qwenlm.github.io/blog"; const $ = load(await ofetch_default(blogUrl)); const list = $("article.post-entry").toArray().map((item) => { item = $(item); const pubDate = parseDate(item.find(".entry-footer span").attr("title").trim().replace(/\+0800$/, "")); return { title: item.find("header.entry-header h2").text().trim(), link: item.find(".entry-link").attr("href"), pubDate }; }); return { title: "Qwen Blog", link: blogUrl, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { item.description = load(await ofetch_default(item.link))("main").html(); return item; }))) }; } }; //#endregion export { route };