feat: add route of 'front-end-rss.now.sh' (#5898)

* feat: add route of 'front-end-rss.now.sh'

* fix: add author for each item

* fix: wrong key property

* fix: set category title as description

* change route name
This commit is contained in:
Henry Wang
2020-10-19 11:49:57 +01:00
committed by GitHub
3 changed files with 35 additions and 0 deletions
+5
View File
@@ -660,6 +660,11 @@ GitHub 官方也提供了一些 RSS:
<Route author="hellodword" example="/galaxylab" path="/galaxylab">
</Route>
## 前端技术文章
<Route author="laampui" example="/frontend" path="/frontend" :paramsDesc="['分类']">
</Route>
## 前端艺术家 && 飞冰早报
### 列表
+3
View File
@@ -2063,6 +2063,9 @@ router.get('/szse/rule', require('./routes/szse/rule'));
// 前端艺术家每日整理&&飞冰早报
router.get('/jskou/:type?', require('./routes/jskou/index'));
// 前端
router.get('/front-end-rss', require('./routes/frontend/index'));
// 国家应急广播
router.get('/cneb/yjxx', require('./routes/cneb/yjxx'));
router.get('/cneb/guoneinews', require('./routes/cneb/guoneinews'));
+27
View File
@@ -0,0 +1,27 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got.get(`https://front-end-rss.now.sh/`);
const $ = cheerio.load(response.data);
const fn = Function($($('script')[1]).html() + 'return Array.isArray(LINKS_DATA) ? LINKS_DATA : []');
const items = fn().reduce(
(acc, category) => [
...acc,
...category.items.map((item) => ({
link: item.link,
pubDate: item.date,
title: item.title,
author: category.title,
description: category.title
})),
],
[]
);
ctx.state.data = {
title: '前端技术文章',
link: 'https://front-end-rss.now.sh/',
item: items,
};
};