UNPKG

rsshub

Version:
49 lines (47 loc) 1.35 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { n as processTopics2Feed, t as RUBY_CHINA_HOST } from "./utils-BAJmjxOH.mjs"; import { load } from "cheerio"; //#region lib/routes/ruby-china/topics.ts const route = { path: "/topics/:type?", categories: ["bbs"], example: "/ruby-china/topics", parameters: { type: "主题类型,在 URL 可以找到" }, name: "主题", maintainers: ["ahonn"], description: `未登录状态下抓取页面非实时更新 | 主题类型 | type | | -------- | ----------- | | 精华贴 | excellent | | 优质帖子 | popular | | 无人问津 | no\\_reply | | 最新回复 | last\\_reply | | 最新发布 | last |`, handler }; const types = /* @__PURE__ */ new Map([ ["excellent", "精华贴"], ["popular", "优质帖子"], ["no_reply", "无人问津"], ["last_reply", "最新回复"], ["last", "最新发布"] ]); async function handler(ctx) { const { type } = ctx.req.param(); let title = "Ruby China"; let link = `${RUBY_CHINA_HOST}/topics`; const typeName = type ? types.get(type) : void 0; if (typeName) { title += ` - ${typeName}`; link += `/${type}`; } const result = await processTopics2Feed(load(await rofetch(link))(".topics .topic").toArray()); return { title, link, description: title, item: result }; } //#endregion export { route };