rsshub
Version:
Make RSS Great Again!
64 lines (62 loc) • 2.03 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 { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { n as ossUrl, r as rootUrl, t as ProcessFeed } from "./utils-BEAy1lIf.mjs";
import { load } from "cheerio";
//#region lib/routes/aisixiang/zhuanti.ts
const route = {
path: "/zhuanti/:id",
categories: ["reading"],
example: "/aisixiang/zhuanti/211",
parameters: { id: "专题 ID, 可在对应专题 URL 中找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "专题",
maintainers: ["nczitzk"],
handler,
description: `::: tip
更多专题请见 [关键词](http://www.aisixiang.com/zhuanti/)
:::`
};
async function handler(ctx) {
const id = ctx.req.param("id");
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 30;
const currentUrl = new URL(`zhuanti/${id}.html`, rootUrl).href;
const { data: response } = await got_default(currentUrl);
const $ = load(response);
const title = $("div.tips h2").first().text();
const items = $("div.article-title").slice(0, limit).toArray().map((item) => {
item = $(item);
const a = item.find("a");
return {
title: a.text(),
link: new URL(a.prop("href"), rootUrl).href,
author: a.text().split(":")[0],
pubDate: timezone(parseDate(item.find("span").text()), 8)
};
});
return {
item: await ProcessFeed(limit, cache_default.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
description: $("div.tips p").text(),
language: "zh-cn",
image: new URL("images/logo_zhuanti.jpg", ossUrl).href,
subtitle: title
};
}
//#endregion
export { route };