feat(route): 支持前端早早聊文章 (#11604)

* feat: add route for zaozao.run

Signed-off-by: shaomingbo <shaomingbo@microbt.com>

* chore: add maintainer

Signed-off-by: shaomingbo <shaomingbo@microbt.com>

* docs: adjust route tag

Signed-off-by: shaomingbo <shaomingbo@microbt.com>

* refactor: adjust fetch data method

Signed-off-by: shaomingbo <shaomingbo@microbt.com>

* Update lib/v2/zaozao/radar.js

* Update radar.js

Signed-off-by: shaomingbo <shaomingbo@microbt.com>
Co-authored-by: shaomingbo <shaomingbo@microbt.com>
This commit is contained in:
shaomingbo 2023-01-14 22:49:21 +08:00 committed by GitHub
parent b4c1b2accb
commit ef5275cacd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 0 deletions

View File

@ -1300,3 +1300,15 @@ GitHub 官方也提供了一些 RSS:
### 热门
<Route author="SirM2z" example="/zcfy/hot" path="/zcfy/hot"/>
## 前端早早聊
### 文章
<Route author="shaomingbo" example="/zaozao/article/quality" path="/zaozao/article/:type?" :paramsDesc="['文章分类']" radar="1">
| 精品推荐 | 技术干货 | 职场成长 | 社区动态 | 组件物料 | 行业动态 |
| --------- | -------- | -------- | --------- | -------- | -------- |
| recommend | quality | growth | community | material | industry |
</Route>

36
lib/v2/zaozao/article.js Normal file
View File

@ -0,0 +1,36 @@
const { parseDate } = require('@/utils/parse-date');
const got = require('@/utils/got');
module.exports = async (ctx) => {
const { type = 'recommend' } = ctx.params;
const response = await got({
method: 'put',
url: `https://e.zaozao.run/article/page/${type}`,
headers: {
Referer: `https://www.zaozao.run/`,
},
body: JSON.stringify({
pageNo: 1,
pageSize: 100,
}),
});
const { status, statusMessage } = response;
if (status !== 200) {
throw new Error(statusMessage);
}
const { data } = response.data;
ctx.state.data = {
title: `前端早早聊 - 文章`,
link: `https://www.zaozao.run/article/${type}`,
description: `前端早早聊 - 文章`,
item: data.map((item) => ({
title: item.title,
link: item.url,
author: item.recommenderName,
pubDate: parseDate(item.updateAt),
})),
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/article/:type?': ['shaomingbo'],
};

13
lib/v2/zaozao/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'zaozao.run': {
_name: '前端早早聊',
www: [
{
title: '文章',
docs: 'https://docs.rsshub.app/programming.html#qian-duan-zao-zao-liao',
source: ['/article/:type'],
target: '/zaozao/article/:type',
},
],
},
};

3
lib/v2/zaozao/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/article/:type?', require('./article'));
};