rsshub
Version:
Make RSS Great Again!
90 lines (88 loc) • 2.75 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./md5-C8GRvctM.mjs";
import "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { r as processImage } from "./utils-Vxf_K345.mjs";
import { t as auth_default } from "./auth-Cby6FaL3.mjs";
//#region lib/routes/zhihu/xhu/topic.ts
const route = {
path: "/xhu/topic/:topicId",
categories: ["social-media"],
example: "/zhihu/xhu/topic/19566035",
parameters: { topicId: "话题ID" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["www.zhihu.com/topic/:topicId/:type"] }],
name: "xhu - 话题",
maintainers: ["JimenezLi"],
handler
};
async function handler(ctx) {
const xhuCookie = await auth_default.getCookie();
const topicId = ctx.req.param("topicId");
const link = `https://www.zhihu.com/topic/${topicId}/newest`;
const listRes = (await got_default({
method: "get",
url: `https://api.zhihuvvv.workers.dev/topics/${topicId}/feeds/timeline_activity?before_id=0&limit=20`,
headers: {
Referer: "https://api.zhihuvvv.workers.dev",
Cookie: xhuCookie
}
})).data.data;
return {
title: `知乎话题-${topicId}`,
link,
item: listRes.map(({ target: item }) => {
const type = item.type;
let title = "";
let description = "";
let link$1 = "";
let pubDate = /* @__PURE__ */ new Date();
let author = "";
switch (type) {
case "answer":
title = `${item.question.title}-${item.author.name}的回答:${item.excerpt}`;
description = `<strong>${item.question.title}</strong><br>${item.author.name}的回答<br/>${processImage(item.content)}`;
link$1 = `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`;
pubDate = parseDate(item.updated_time * 1e3);
author = item.author.name;
break;
case "question":
title = item.title;
description = item.title;
link$1 = `https://www.zhihu.com/question/${item.id}`;
pubDate = parseDate(item.created * 1e3);
break;
case "article":
title = item.title;
description = item.excerpt;
link$1 = item.url;
pubDate = parseDate(item.created * 1e3);
break;
default: description = `未知类型 ${topicId}.${type},请点击<a href="https://github.com/DIYgod/RSSHub/issues">链接</a>提交issue`;
}
return {
title,
description,
author,
pubDate,
guid: link$1,
link: link$1
};
})
};
}
//#endregion
export { route };