rsshub
Version:
Make RSS Great Again!
65 lines (63 loc) • 2.85 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
//#region lib/routes/bossdesign/index.ts
const route = {
path: "/:category?",
categories: ["design"],
example: "/bossdesign",
parameters: { category: "分类,可在对应分类页 URL 中找到,留空为全部" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "分类",
maintainers: ["TonyRL"],
handler,
description: `| Boss 笔记 | 电脑日志 | 素材资源 | 设计师神器 | 设计教程 | 设计资讯 |
| --------- | --------------- | ---------------- | --------------- | --------------- | ------------------- |
| note | computer-skills | design-resources | design-software | design-tutorial | design\_information |`
};
async function handler(ctx) {
const category = ctx.req.param("category");
const limit = Number.parseInt(ctx.req.query("limit"), 10) || void 0;
const baseUrl = "https://www.bossdesign.cn";
const currentCategory = await cache_default.tryGet(`bossdesign:categories:${category}`, async () => {
const { data: categories } = await got_default(`${baseUrl}/wp-json/wp/v2/categories`);
return categories.find((item) => item.slug === category || item.name === category);
});
const categoryId = currentCategory?.id;
const { data: posts } = await got_default(`${baseUrl}/wp-json/wp/v2/posts`, { searchParams: {
categories: categoryId,
per_page: limit,
_embed: ""
} });
const items = posts.map((item) => ({
title: item.title.rendered,
description: item.content.rendered,
pubDate: parseDate(item.date_gmt),
updated: parseDate(item.modified_gmt),
link: item.link,
guid: item.guid.rendered,
category: [...new Set([...item._embedded["wp:term"][0].map((item$1) => item$1.name), ...item._embedded["wp:term"][1].map((item$1) => item$1.name)])]
}));
return {
title: currentCategory?.name ? `${currentCategory.name} | Boss设计` : "Boss设计 | 收集国外设计素材网站的资源平台。",
description: currentCategory?.description ?? "Boss设计-收集国外设计素材网站的资源平台。专注于收集国外设计素材和国外设计网站,以及超实用的设计师神器,只为设计初学者和设计师提供海量的资源平台。..",
image: currentCategory?.cover ?? `${baseUrl}/wp-content/themes/pinghsu/images/Bossdesign-ico.ico`,
link: currentCategory?.link ?? baseUrl,
item: items
};
}
//#endregion
export { route };