UNPKG

rsshub

Version:
40 lines (39 loc) 1.28 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/latexstudio/home.ts const route = { path: "/home", categories: ["blog"], example: "/latexstudio/home", name: "首页", maintainers: ["kt286", "nczitzk"], handler }; async function handler() { const rootUrl = "https://www.latexstudio.net/articles/"; const response = await rofetch(rootUrl); const $ = load(response); const list = $("div.article-list").find("h3.article-title").toArray().slice(0, 20).map((item) => { const a = $(item).find("a"); return { title: a.text(), link: new URL(a.attr("href"), rootUrl).href }; }); return { title: "LaTeX 开源小屋", link: rootUrl, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const res = await rofetch(item.link); const content = load(res); item.pubDate = timezone(parseDate(content("div.entry-meta ul li").eq(3).text().replace("发布日期:", "")), 8); item.description = content("div.article-text").html(); return item; }))) }; } //#endregion export { route };