rsshub
Version:
Make RSS Great Again!
65 lines (63 loc) • 1.94 kB
JavaScript
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/informedainews/docs.ts
const route = {
path: "/zh-Hans/docs/:type",
categories: ["new-media"],
example: "/informedainews/zh-Hans/docs/world-news-daily",
parameters: { type: "world-news-daily|tech-enthusiast-weekly|ai-enthusiast-daily" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: [
"informedainews.com",
"informedainews.com/zh-Hans/docs/:type",
"informedainews.com/docs/:type"
],
target: "/zh-Hans/docs/:type"
}],
name: "知闻AI",
maintainers: ["guicaiyue"],
handler
};
async function handler(ctx) {
const { type } = ctx.req.param();
const $ = load(await ofetch_default(`https://informedainews.com/zh-Hans/docs/${type}`));
const list = $("li.theme-doc-sidebar-item-category ul li").toArray().map((item) => {
item = $(item);
const a = item.find("a").first();
const text = a.text();
const start = text.indexOf("(");
const end = text.indexOf(")");
const date = text.substring(start + 1, end);
return {
title: text,
link: `https://informedainews.com${a.attr("href")}`,
pubDate: parseDate(date),
author: "AI"
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load(await ofetch_default(item.link))(".theme-doc-markdown.markdown").first().html();
return item;
})));
return {
title: `${type} docs`,
link: `https://informedainews.com/zh-Hans/docs/${type}`,
item: items
};
}
//#endregion
export { route };