UNPKG

rsshub

Version:
45 lines (43 loc) 1.27 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 cache_default } from "./cache-Bo__VnGm.mjs"; import { load } from "cheerio"; //#region lib/routes/naturalism/new.ts const route = { path: "/", categories: ["other"], example: "/naturalism", radar: [{ source: ["naturalism.org"] }], name: "What's New", maintainers: ["TonyRL"], handler, url: "naturalism.org" }; async function handler() { const baseUrl = "https://naturalism.org"; const $ = load(await ofetch_default(baseUrl)); const list = $(".view-what-s-new .field-content a").toArray().map((element) => { const a = $(element); return { title: a.text(), link: new URL(a.attr("href"), baseUrl).href }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $$1 = load(await ofetch_default(item.link)); $$1("#content").find("h1").remove(); item.description = $$1("#content").html(); return item; }))); return { title: $("head title").text(), link: baseUrl, image: `${baseUrl}/sites/naturalism.org/files/swirl-logo.png`, item: items }; } //#endregion export { route };