UNPKG

rsshub

Version:
75 lines (72 loc) 2.97 kB
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { t as got_default } from "./got-BTowW50G.mjs"; import { t as timezone } from "./timezone-BBvDwS_3.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) => { const $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() ?? void 0 }); 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 };