UNPKG

rsshub

Version:
52 lines (50 loc) 1.54 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { l as processItems, s as fetchData, t as apiArticleRootUrl, u as rootUrl } from "./util-B64gnjsQ.mjs"; //#region lib/routes/huxiu/tag.ts const route = { path: "/tag/:id", categories: ["new-media"], example: "/huxiu/tag/291", parameters: { id: "标签 id,可在对应标签页 URL 中找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: true, supportScihub: false }, name: "标签", maintainers: [ "xyqfer", "HenryQW", "nczitzk", "TimoYoung" ], handler, description: `更多标签请参见 [标签](https://www.huxiu.com/tags)` }; async function handler(ctx) { const id = ctx.req.param("id"); const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 10; const apiUrl = new URL("/v3/tag/articleList", apiArticleRootUrl).href; const currentUrl = new URL(`tag/${id}.html`, rootUrl).href; const { data: response } = await got_default.post(apiUrl, { form: { platform: "www", tag_id: id } }); return { item: await processItems(response.data.datalist, limit, cache_default.tryGet), ...await fetchData(currentUrl) }; } //#endregion export { route };