rsshub
Version:
Make RSS Great Again!
43 lines (41 loc) • 1.44 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 "./cache-Bo__VnGm.mjs";
import "./render-BQo6B4tL.mjs";
import { t as getData } from "./utils-CegEFYeG.mjs";
import { load } from "cheerio";
//#region lib/routes/psyche/topic.ts
const route = {
path: "/topic/:topic",
categories: ["new-media"],
example: "/psyche/topic/therapeia",
parameters: { topic: "Topic" },
radar: [{ source: ["psyche.co/:topic"] }],
name: "Topics",
maintainers: ["emdoe"],
handler,
description: "Supported categories: Therapeia, Eudaimonia, and Poiesis."
};
async function handler(ctx) {
const url = `https://psyche.co/${ctx.req.param("topic")}`;
const $ = load(await ofetch_default(url));
const data = JSON.parse($("script#__NEXT_DATA__").text());
const articles = data.props.pageProps.articles;
const prefix = `https://psyche.co/_next/data/${data.buildId}`;
const items = await getData(Object.keys(articles).flatMap((type) => articles[type].edges.map((item) => ({
title: item.node.title,
link: `https://psyche.co/${type}/${item.node.slug}`,
json: `${prefix}/${type}/${item.node.slug}.json`
}))));
return {
title: `Psyche | ${data.props.pageProps.section.title}`,
link: url,
description: data.props.pageProps.section.metaDescription,
item: items
};
}
//#endregion
export { route };