UNPKG

rsshub

Version:
59 lines (57 loc) 1.75 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import { t as ViewType } from "./types-gOySfSXJ.mjs"; import "./logger-C4avouvV.mjs"; import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs"; import markdownit from "markdown-it"; //#region lib/routes/rsshub/routes.ts const md = markdownit({ breaks: true, html: true }); const route = { path: "/routes/:lang?", categories: ["program-update"], view: ViewType.Notifications, example: "/rsshub/routes/en", parameters: { lang: { description: "Language", options: [{ label: "Chinese", value: "zh" }, { label: "English", value: "en" }], default: "en" } }, radar: [{ source: ["docs.rsshub.app/*"], target: "/routes" }], name: "New routes", maintainers: ["DIYgod"], handler, url: "docs.rsshub.app/*" }; async function handler(ctx) { const isEnglish = ctx.req.param("lang") !== "zh"; const data = await ofetch_default("https://docs.rsshub.app/routes.json"); const items = Object.entries(data).flatMap(([namespace, namespaceData]) => Object.entries(namespaceData.routes).map(([routePath, routeData]) => ({ title: `${namespaceData.name} - ${routeData.name}`, description: routeData.description ? md.render(routeData.description) : "", link: `https://docs.rsshub.app/${isEnglish ? "" : "zh/"}routes/${namespace}`, category: routeData.categories, guid: `/${namespace}${routePath === "/" ? "" : routePath}`, author: routeData.maintainers.join(", ") }))); return { title: isEnglish ? "RSSHub has new routes" : "RSSHub 有新路由啦", link: "https://docs.rsshub.app", description: isEnglish ? "Everything is RSSible" : "万物皆可 RSS", language: isEnglish ? "en-us" : "zh-cn", item: items }; } //#endregion export { route };