UNPKG

rsshub

Version:
45 lines (44 loc) 1.52 kB
import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as got_default } from "./got-DUpa1V3-.mjs"; import { n as getList, t as getData } from "./utils-B4ek7QWg.mjs"; import { load } from "cheerio"; //#region lib/routes/grist/featured.ts const route = { path: "/featured", categories: ["new-media"], example: "/grist/featured", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["grist.org/"] }], name: "Featured", maintainers: ["Rjnishant530"], handler, url: "grist.org/" }; async function handler() { const baseUrl = "https://grist.org/"; const { data: response } = await got_default(baseUrl); const $ = load(response); const listItems = $("li.hp-featured__tease").toArray().map((item) => { return { link: $(item).find(".small-tease__link").attr("href").split("/").at(-2) }; }); const itemData = await Promise.all(listItems.map((item) => cache_default.tryGet(item.link, async () => (await getData(`https://grist.org/wp-json/wp/v2/posts?slug='${item.link}'&_embed`))[0]))); return { title: "Gist Featured Articles", link: baseUrl, item: await getList(itemData), description: "Featured Articles on Grist.org", logo: "https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=192", icon: "https://grist.org/wp-content/uploads/2021/03/cropped-Grist-Favicon.png?w=32", language: "en-us" }; } //#endregion export { route };