UNPKG

rsshub

Version:
61 lines (59 loc) 1.58 kB
import "./dist-Bog6z_OM.mjs"; import { t as config } from "./config-MQ-7ebJ_.mjs"; import { t as ViewType } from "./types-gOySfSXJ.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; //#region lib/routes/zhihu/hot.ts const route = { path: "/hot/:category?", categories: ["social-media"], example: "/zhihu/hot", view: ViewType.Articles, features: { requireConfig: [{ name: "ZHIHU_COOKIES", description: "", optional: true }], requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false }, name: "知乎热榜", maintainers: [ "nczitzk", "pseudoyu", "DIYgod" ], handler }; async function handler(ctx) { if (ctx.req.param("category")) { ctx.set("redirect", `/zhihu/hot`); return null; } const cookie = config.zhihu.cookies; return { title: `知乎热榜`, link: `https://www.zhihu.com/hot`, item: (await got_default({ method: "get", url: `https://api.zhihu.com/topstory/hot-lists/total?limit=10&reverse_order=0`, headers: { Cookie: cookie } })).data.data.map((item) => { return { link: `https://www.zhihu.com/question/${item.target.url ? item.target.url.split("/").pop() : String(item.target.id)}`, title: item.target.title, pubDate: parseDate(item.target.created * 1e3), description: item.target.excerpt ? `<p>${item.target.excerpt}</p>` : "" }; }) }; } //#endregion export { route };