UNPKG

rsshub

Version:
81 lines (77 loc) 2.93 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 { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/simpleinfo/index.ts init_esm_shims(); const route = { path: "/:category?", categories: ["new-media"], example: "/simpleinfo", parameters: { category: "分类名" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["blog.simpleinfo.cc/blog/:category"], target: "/:category" }], name: "志祺七七", maintainers: ["haukeng"], handler, description: `| 夥伴聊聊 | 專案設計 | | -------- | -------- | | work | talk | | 國內外新聞 | 政治百分百 | 社會觀察家 | 心理與哲學 | | ---------- | ---------- | ---------- | --------------------- | | news | politics | society | psychology-philosophy | | 科學大探索 | 環境與健康 | ACG 快樂聊 | 好書籍分享 | 其它主題 | | ---------- | ------------------ | ---------- | ------------ | ------------ | | science | environment-health | acg | book-sharing | other-topics |` }; async function handler(ctx) { const category = ctx.req.param("category"); const link = `https://blog.simpleinfo.cc${category ? category === "work" || category === "talk" ? `/blog/${category}` : `/shasha77?category=${category}` : "/shasha77"}`; const $ = load((await got_default(link)).data); const title = `${$(".-active").text()} - 簡訊設計`; $(".-ad").remove(); const list = $(".article-item").toArray().map((item) => { item = $(item); return { title: item.find(".title").text(), link: item.find("a").first().attr("href"), category: item.find(".category").text() }; }); return { title, link, language: "zh-tw", item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load((await got_default(item.link)).data); item.author = content("meta[property=\"article:author\"]").attr("content"); item.pubDate = timezone(parseDate(content("meta[property=\"article:published_time\"]").attr("content")), 8); item.description = art(path.join(__dirname, "templates/description-40eff032.art"), { image: content("meta[property=\"og:image\"]").attr("content"), description: content(".article-content").first().html() }); return item; }))) }; } //#endregion export { route };