UNPKG

rsshub

Version:
61 lines (59 loc) 1.97 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./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 "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as timezone } from "./timezone-CA9Huotp.mjs"; import { n as ossUrl, r as rootUrl, t as ProcessFeed } from "./utils-Cknwxv6D.mjs"; import { load } from "cheerio"; //#region lib/routes/aisixiang/column.ts const route = { path: "/column/:id", categories: ["reading"], example: "/aisixiang/column/722", parameters: { id: "栏目 ID, 可在对应栏目 URL 中找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "栏目", maintainers: ["HenryQW", "nczitzk"], handler }; 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(`/data/search?column=${id}`, rootUrl).href; const { data: response } = await got_default(currentUrl); const $ = load(response); const title = $("div.article-title a").first().text().replaceAll("[]", ""); const items = $("div.article-title").slice(0, limit).toArray().map((item) => { item = $(item); const a = item.find("a[title]"); 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").text(), language: "zh-cn", image: new URL("images/logo.jpg", ossUrl).href, subtitle: title }; } //#endregion export { route };