UNPKG

rsshub

Version:
62 lines (60 loc) 1.8 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/0x80/index.ts const route = { path: "/blog", categories: ["blog"], example: "/0x80/blog", url: "0x80.pl/notesen.html", name: "Articles", maintainers: ["xnum"], handler }; function extractDateFromURL(url) { const match = url.match(/\d{4}-\d{2}-\d{2}/); return match ? match[0] : null; } async function handler() { const baseUrl = "http://0x80.pl/"; const targetUrl = `${baseUrl}notesen.html`; const $ = load((await got_default({ method: "get", url: targetUrl })).data); const list = $("a.reference.external").toArray().map((item) => { item = $(item); const link = item.attr("href") || ""; return { title: item.text() || "", link, pubDate: extractDateFromURL(link), category: "Uncategoried" }; }).filter((item) => item.link.startsWith("notesen")); return { title: "0x80.pl articles", link: targetUrl, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $$1 = load((await got_default({ method: "get", url: `${baseUrl}${item.link}` })).data); const author = $$1("tr.author.field td.field-body").text(); const articlePubDate = $$1("tr.added-on.field td.field-body").text(); item.author = author; item.pubDate = parseDate(item.pubDate || articlePubDate); item.description = $$1("div.document").first().html(); return item; }))) }; } //#endregion export { route };