UNPKG

rsshub

Version:
50 lines (48 loc) 1.43 kB
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 "./is-worker-DESPicPc.mjs"; import "./cache-SV6W5EPy.mjs"; import { t as getData } from "./utils-RmJAkpFX.mjs"; import { load } from "cheerio"; //#region lib/routes/psyche/type.ts const route = { path: "/type/:type", categories: ["new-media"], example: "/psyche/type/ideas", parameters: { type: "Type" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["psyche.co/:type"] }], name: "Types", maintainers: ["emdoe"], handler, description: `Supported types: Ideas, Guides, and Films.` }; async function handler(ctx) { const type = ctx.req.param("type"); const capitalizedType = type.charAt(0).toUpperCase() + type.slice(1); const url = `https://psyche.co/${type}`; const $ = load(await ofetch_default(url)); const data = JSON.parse($("script#__NEXT_DATA__").text()); const prefix = `https://psyche.co/_next/data/${data.buildId}`; const items = await getData(data.props.pageProps.articles.map((item) => ({ title: item.title, link: `${url}/${item.slug}`, json: `${prefix}/${type}/${item.slug}.json` }))); return { title: `Psyche | ${capitalizedType}`, link: url, item: items }; } //#endregion export { route };