UNPKG

rsshub

Version:
78 lines (76 loc) 2.01 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 "./cache-Bo__VnGm.mjs"; import "./render-BQo6B4tL.mjs"; import { n as getData, t as getBuildId } from "./utils-DF3hXsqD.mjs"; //#region lib/routes/aeon/category.ts const route = { path: "/category/:category", categories: ["new-media"], example: "/aeon/category/philosophy", parameters: { category: { description: "Category", options: [ { value: "philosophy", label: "Philosophy" }, { value: "science", label: "Science" }, { value: "psychology", label: "Psychology" }, { value: "society", label: "Society" }, { value: "culture", label: "Culture" } ] } }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["aeon.co/:category"] }], name: "Categories", maintainers: ["emdoe"], handler }; async function handler(ctx) { const category = ctx.req.param("category").toLowerCase(); const url = `https://aeon.co/category/${category}`; const section = (await ofetch_default(`https://aeon.co/_next/data/${await getBuildId()}/${category}.json`)).pageProps.section; const items = await getData(section.articles.edges.map(({ node }) => ({ title: node.title, description: node.standfirstLong, author: node.authors.map((author) => author.displayName).join(", "), link: `https://aeon.co/${node.type}s/${node.slug}`, pubDate: parseDate(node.createdAt), category: [node.section.title, ...node.topics.map((topic) => topic.title)], image: node.image.url, type: node.type, slug: node.slug }))); return { title: `AEON | ${section.title}`, link: url, description: section.metaDescription, item: items }; } //#endregion export { route };