UNPKG

rsshub

Version:
91 lines (89 loc) 2.38 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import { i as rootUrl, n as language, r as processItems, t as author } from "./util-CGGCO7j-.mjs"; //#region lib/routes/ifun/n/category.ts const handler = async (ctx) => { const { id } = ctx.req.param(); const limit = Number.parseInt(ctx.req.query("limit") ?? "30", 10); const targetUrl = rootUrl; const apiUrl = new URL(`api/articles/${id ? "categoryId" : "all"}`, rootUrl).href; const apiCategoryUrl = new URL("api/categories/all", rootUrl).href; const apiResponse = await ofetch_default(apiUrl, { query: { datasrc: id ? "categoriesall" : "articles", current: 1, size: limit, categoryId: id } }); const categoryName = (await ofetch_default(apiCategoryUrl, { query: { datasrc: "categories" } })).data.find((item) => item.categoryid === id)?.category; const items = processItems(apiResponse.data.records, limit); return { title: `${author}${categoryName ? ` - ${categoryName}` : ""}`, description: categoryName, link: targetUrl, item: items, allowEmpty: true, author, language }; }; const route = { path: "/n/category/:id?", name: "盐选故事分类", url: "n.ifun.cool", maintainers: ["nczitzk"], handler, example: "/ifun/n/category", parameters: { id: "分类 id,默认为空,即全部,见下表" }, description: ` | 名称 | ID | | -------- | --- | | 全部 | | | 通告 | 1 | | 故事盐选 | 2 | | 趣集精选 | 3 | `, categories: ["new-media"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportRadar: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [ { source: ["n.ifun.cool"], target: "/n/category/:id?" }, { title: "全部", source: ["n.ifun.cool"], target: "/n/category" }, { title: "通告", source: ["n.ifun.cool"], target: "/n/category/1" }, { title: "盐选故事", source: ["n.ifun.cool"], target: "/n/category/2" }, { title: "趣集精选", source: ["n.ifun.cool"], target: "/n/category/3" } ], view: ViewType.Articles }; //#endregion export { handler, route };