UNPKG

rsshub

Version:
62 lines (60 loc) 1.84 kB
import { n as init_esm_shims, t as __dirname } from "./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 "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/pts/projects.ts init_esm_shims(); const route = { path: "/projects", categories: ["traditional-media"], example: "/pts/projects", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["news.pts.org.tw/projects", "news.pts.org.tw/"] }], name: "數位敘事", maintainers: ["nczitzk"], handler, url: "news.pts.org.tw/projects" }; async function handler() { const currentUrl = `https://news.pts.org.tw/projects`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); const items = $("h3 a").toArray().map((item) => { item = $(item); const projectDiv = item.parent().parent(); const description = projectDiv.find("p").text(); return { title: item.text(), link: item.attr("href"), pubDate: parseDate(projectDiv.find("time").text()), description: art(path.join(__dirname, "templates/description-33e81d41.art"), { image: projectDiv.parent().find(".cover-fit")?.attr("src") ?? projectDiv.parent().parent().find(".cover-fit").attr("src"), description: description ? `<p>${description}</p>` : "" }) }; }); return { title: $("title").text().replace(/第\d+頁 | /, ""), link: currentUrl, item: items }; } //#endregion export { route };