rsshub
Version:
Make RSS Great Again!
58 lines (56 loc) • 1.91 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import "./parse-date-BrP7mxXf.mjs";
import "./cache-Bo__VnGm.mjs";
import "./render-BQo6B4tL.mjs";
import "./timezone-D8cuwzTY.mjs";
import { i as rootUrl, n as parseArticle, r as parseResult, t as apiRootUrl } from "./utils-BKoJeQXr.mjs";
//#region lib/routes/utgd/category.ts
const route = {
path: "/category/:category?",
categories: ["new-media"],
example: "/utgd/category/method",
parameters: { category: "分类,可在对应分类页的 URL 中找到,默认为方法" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["utgd.net/category/s/:category", "utgd.net/"],
target: "/category/:category"
}],
name: "分类",
maintainers: ["nczitzk"],
handler,
description: `| 方法 | 观点 |
| ------ | ------- |
| method | opinion |`
};
async function handler(ctx) {
const category = ctx.req.param("category") ?? "method";
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 9;
const apiUrl = `${apiRootUrl}/api/v2/categories`;
const currentUrl = `${rootUrl}/category/s/${category}`;
const categoryData = await ofetch_default(`${apiRootUrl}/api/v2/category/slug/${category}/`);
const list = parseResult((await ofetch_default(`${apiUrl}/${categoryData.id}/related_articles`, { query: {
page: 1,
page_size: limit
} })).results, limit);
const items = await Promise.all(list.map((item) => parseArticle(item)));
return {
title: `UNTAG - ${categoryData.category_name}`,
link: currentUrl,
item: items,
image: categoryData.category_image,
description: categoryData.category_description
};
}
//#endregion
export { route };