UNPKG

rsshub

Version:
62 lines (60 loc) 2.02 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as timezone } from "./timezone-CA9Huotp.mjs"; import { load } from "cheerio"; //#region lib/routes/stanford/blog.ts const route = { path: ["/hazyresearch/blog"], categories: ["blog"], example: "/stanford/hazyresearch/blog", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["hazyresearch.stanford.edu/blog"] }], name: "Hazy Research Blog", maintainers: ["dvorak0"], handler, url: "hazyresearch.stanford.edu/blog" }; async function handler() { const baseUrl = "https://hazyresearch.stanford.edu"; const currentUrl = `${baseUrl}/blog`; const { data: response } = await got_default(currentUrl); const nextDataRaw = load(response)("script#__NEXT_DATA__").text(); const nextData = JSON.parse(nextDataRaw); const posts = nextData.props.pageProps.posts || []; const buildId = nextData.buildId; const list = posts.map((post) => ({ title: post.title, link: `${baseUrl}/blog/${post.slug}`, api: `${baseUrl}/_next/data/${buildId}/blog/${post.slug}.json`, author: post.author, pubDate: timezone(parseDate(post.dateString, "MMM D, YYYY"), -7) })); return { title: "Hazy Research Blog", link: currentUrl, description: "Research updates from Stanford Hazy Research", language: "en", item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const { data: html } = await got_default(item.link); item.description = load(html)("main [class^=\"Post_content\"]").html() || ""; return item; }))) }; } //#endregion export { route };