UNPKG

rsshub

Version:
48 lines (46 loc) 1.51 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 "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { n as SUB_URL, r as article_default, t as SUB_NAME_PREFIX } from "./const-mWp6lZu-.mjs"; //#region lib/routes/4khd/category.ts const route = { path: "/category/:category", categories: ["picture"], example: "/4khd/category/cosplay", parameters: { category: "Category" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false, nsfw: true }, radar: [{ source: ["www.4khd.com/pages/:category"], target: "/category/:category" }], name: "Category", maintainers: ["AiraNadih"], handler, url: "www.4khd.com/" }; async function handler(ctx) { const limit = Number.parseInt(ctx.req.query("limit")) || 20; const category = ctx.req.param("category"); const categoryUrl = `${SUB_URL}pages/${category}/`; const { data: [{ id: categoryId }] } = await got_default(`${SUB_URL}wp-json/wp/v2/categories?slug=${category === "album" ? "photo" : category}`); const { data: posts } = await got_default(`${SUB_URL}wp-json/wp/v2/posts?categories=${categoryId}&per_page=${limit}`); return { title: `${SUB_NAME_PREFIX} - Category: ${category}`, link: categoryUrl, item: posts.map((post) => article_default(post)) }; } //#endregion export { route };