rsshub
Version:
Make RSS Great Again!
51 lines (49 loc) • 1.4 kB
JavaScript
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs";
import { n as processTopics2Feed, t as RUBY_CHINA_HOST } from "./utils-CeArbOZW.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 response = await rofetch(link);
const list = load(response)(".topics .topic").toArray();
const result = await processTopics2Feed(list);
return {
title,
link,
description: title,
item: result
};
}
//#endregion
export { route };