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:
parent
b4c1b2accb
commit
ef5275cacd
|
|
@ -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>
|
||||
|
|
@ -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),
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/article/:type?': ['shaomingbo'],
|
||||
};
|
||||
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/article/:type?', require('./article'));
|
||||
};
|
||||
Loading…
Reference in New Issue