UNPKG

rsshub

Version:
38 lines (37 loc) 1.24 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 { t as timezone } from "./timezone-DE--ze1V.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 $ = load(await rofetch(rootUrl)); 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 content = load(await rofetch(item.link)); 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 };