feat(route): byteclicks (#11743)
* feat(route): byteclicks * docs: fix paramsDesc
This commit is contained in:
parent
31c633abf8
commit
4567e3a6eb
|
|
@ -4628,6 +4628,16 @@ QueryString:
|
|||
|
||||
</Route>
|
||||
|
||||
## 字节点击
|
||||
|
||||
### 首页
|
||||
|
||||
<Route author="TonyRL" example="/byteclicks" path="/byteclicks" radar="1" />
|
||||
|
||||
### 标签
|
||||
|
||||
<Route author="TonyRL" example="/byteclicks/tag/人工智能" path="/byteclicks/tag/:tag" radar="1" :paramsDesc="['标签,可在URL中找到']"/>
|
||||
|
||||
## 自由微信
|
||||
|
||||
### 公众号
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseItem } = require('./utils');
|
||||
const baseUrl = 'https://byteclicks.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { data } = await got(`${baseUrl}/wp-json/wp/v2/posts`, {
|
||||
searchParams: {
|
||||
per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 100,
|
||||
},
|
||||
});
|
||||
|
||||
const items = parseItem(data);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '字节点击 - 聚合全球优质资源,跟踪世界前沿科技',
|
||||
description:
|
||||
'byteclicks.com 最专业的前沿科技网站。聚合全球优质资源,跟踪世界前沿科技,精选推荐一些很棒的互联网好资源好工具好产品。寻找有前景好项目、找论文、找报告、找数据、找课程、找电子书上byteclicks!byteclicks.com是投资人、科研学者、学生每天必看的网站。',
|
||||
image: 'https://byteclicks.com/wp-content/themes/RK-Blogger/images/wbolt.ico',
|
||||
link: baseUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/': ['TonyRL'],
|
||||
'/tag/:tag': ['TonyRL'],
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
'byteclicks.com': {
|
||||
_name: '字节点击',
|
||||
'.': [
|
||||
{
|
||||
title: '首页',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#zi-jie-dian-ji',
|
||||
source: ['/'],
|
||||
target: '/byteclicks',
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#zi-jie-dian-ji',
|
||||
source: ['/tag/:tag'],
|
||||
target: '/byteclicks/tag/:tag',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/', require('./index'));
|
||||
router.get('/tag/:tag', require('./tag'));
|
||||
};
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseItem } = require('./utils');
|
||||
const baseUrl = 'https://byteclicks.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { tag } = ctx.params;
|
||||
const { data: search } = await got(`${baseUrl}/wp-json/wp/v2/tags`, {
|
||||
searchParams: {
|
||||
search: tag,
|
||||
per_page: 100,
|
||||
},
|
||||
});
|
||||
const tagData = search.find((item) => item.name === tag);
|
||||
|
||||
const { data } = await got(`${baseUrl}/wp-json/wp/v2/posts`, {
|
||||
searchParams: {
|
||||
per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 100,
|
||||
tags: tagData.id,
|
||||
},
|
||||
});
|
||||
|
||||
const items = parseItem(data);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${tagData.name} - 字节点击`,
|
||||
image: 'https://byteclicks.com/wp-content/themes/RK-Blogger/images/wbolt.ico',
|
||||
link: tagData.link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const parseItem = (data) =>
|
||||
data.map((item) => ({
|
||||
title: item.title.rendered,
|
||||
description: item.content.rendered,
|
||||
pubDate: parseDate(item.date_gmt),
|
||||
link: item.link,
|
||||
}));
|
||||
|
||||
module.exports = {
|
||||
parseItem,
|
||||
};
|
||||
Loading…
Reference in New Issue