rsshub
Version:
Make RSS Great Again!
55 lines (53 loc) • 1.66 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./is-worker-DESPicPc.mjs";
import { t as cache_default } from "./cache-SV6W5EPy.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 };