UNPKG

rsshub

Version:
43 lines (42 loc) 1.4 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { load } from "cheerio"; //#region lib/routes/simonsfoundation/articles.ts const route = { path: "/articles", categories: ["new-media"], example: "/simonsfoundation/articles", name: "Articles", maintainers: ["emdoe"], handler }; async function handler() { const url = "https://www.simonsfoundation.org/news/articles/"; const $ = load(await rofetch(url)); const list = $(".news-links-wrapper").toArray().map((item) => { const $item = $(item); const a = $item.find("a.news-title"); return { title: a.text(), link: a.attr("href"), pubDate: parseDate($item.find(".news-date").text()) }; }); return { title: "Simons Foundation | Articles", link: url, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const capture = load(await rofetch(item.link)); const banner = capture("div.o-page-header__hero").html(); item.author = capture(".m-meta__inherit").text(); capture(".m-block-info__animation").remove(); capture(".o-blocks__left").remove(); capture(".m-tags").remove(); item.description = banner === null ? capture(".o-blocks").html() : banner + capture(".o-blocks").html(); return item; }))) }; } //#endregion export { route };