UNPKG

rsshub

Version:
82 lines (78 loc) 3.15 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as timezone } from "./timezone-CA9Huotp.mjs"; import { Fragment, jsx, jsxs } from "hono/jsx/jsx-runtime"; import { load } from "cheerio"; import { renderToString } from "hono/jsx/dom/server"; import { raw } from "hono/html"; //#region lib/routes/simpleinfo/index.tsx 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 = renderDescription({ image: content("meta[property=\"og:image\"]").attr("content"), description: content(".article-content").first().html() }); return item; }))) }; } const renderDescription = ({ image, description }) => renderToString(/* @__PURE__ */ jsxs(Fragment, { children: [image ? /* @__PURE__ */ jsx("img", { src: image }) : null, description ? /* @__PURE__ */ jsx(Fragment, { children: raw(description) }) : null] })); //#endregion export { route };