Skip to content

Commit

Permalink
feat(route): bossdesign (#13829)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Nov 18, 2023
1 parent 6fb730b commit 7192f48
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/v2/bossdesign/index.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
3 changes: 3 additions & 0 deletions lib/v2/bossdesign/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:category?': ['TonyRL'],
};
13 changes: 13 additions & 0 deletions lib/v2/bossdesign/radar.js
Original file line number Diff line number Diff line change
@@ -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}` : ''}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/bossdesign/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:category?', require('./index'));
};
12 changes: 12 additions & 0 deletions website/docs/routes/design.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ Behance user's profile URL, like [https://www.behance.net/mishapetrick](https://

<Route author="MisteryMonster" example="/blur-studio" path="/blur-studio" />

## Boss 设计 {#boss-she-ji}

### 分类 {#boss-she-ji-fen-lei}

<Route author="TonyRL" example="/bossdesign" path="/bossdesign/:category?" paramsDesc={['分类,可在对应分类页 URL 中找到,留空为全部']} radar="1">

| Boss笔记 | 电脑日志 | 素材资源 | 设计师神器 | 设计教程 | 设计资讯 |
| -------- | ----------- | ---------------- | --------------- | --------------- | ------------------ |
| note | computer-skills | design-resources | design-software | design-tutorial | design_information |

</Route>

## Digic Picture {#digic-picture}

### Works & News {#digic-picture-works-news}
Expand Down

0 comments on commit 7192f48

Please sign in to comment.