diff --git a/lib/v2/bossdesign/index.js b/lib/v2/bossdesign/index.js new file mode 100644 index 00000000000000..3707d73398dd81 --- /dev/null +++ b/lib/v2/bossdesign/index.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { category } = ctx.params; + const limit = parseInt(ctx.query.limit, 10) || undefined; + const baseUrl = 'https://www.bossdesign.cn'; + + const currentCategory = await ctx.cache.tryGet(`bossdesign:categories:${category}`, async () => { + const { data: categories } = await got(`${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(`${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) => item.name), ...item._embedded['wp:term'][1].map((item) => item.name)])], + })); + + ctx.state.data = { + 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, + }; +}; diff --git a/lib/v2/bossdesign/maintainer.js b/lib/v2/bossdesign/maintainer.js new file mode 100644 index 00000000000000..9644afe025ca72 --- /dev/null +++ b/lib/v2/bossdesign/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:category?': ['TonyRL'], +}; diff --git a/lib/v2/bossdesign/radar.js b/lib/v2/bossdesign/radar.js new file mode 100644 index 00000000000000..fa26348f0ebccf --- /dev/null +++ b/lib/v2/bossdesign/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'bossdesign.cn': { + _name: 'Boss 设计', + '.': [ + { + title: '分类', + docs: 'https://docs.rsshub.app/routes/design#boss-she-ji', + source: ['/:category?', '/'], + target: (params) => `/bossdesign${params.category ? `/${params.category}` : ''}`, + }, + ], + }, +}; diff --git a/lib/v2/bossdesign/router.js b/lib/v2/bossdesign/router.js new file mode 100644 index 00000000000000..9885c36f134815 --- /dev/null +++ b/lib/v2/bossdesign/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:category?', require('./index')); +}; diff --git a/website/docs/routes/design.mdx b/website/docs/routes/design.mdx index 7ed7a96e3d59d0..dd0df8ed2bc28e 100644 --- a/website/docs/routes/design.mdx +++ b/website/docs/routes/design.mdx @@ -34,6 +34,18 @@ Behance user's profile URL, like [https://www.behance.net/mishapetrick](https:// +## Boss 设计 {#boss-she-ji} + +### 分类 {#boss-she-ji-fen-lei} + + + +| Boss笔记 | 电脑日志 | 素材资源 | 设计师神器 | 设计教程 | 设计资讯 | +| -------- | ----------- | ---------------- | --------------- | --------------- | ------------------ | +| note | computer-skills | design-resources | design-software | design-tutorial | design_information | + + + ## Digic Picture {#digic-picture} ### Works & News {#digic-picture-works-news}