feat(route): add Foresight News article (#9295)
This commit is contained in:
parent
3965da8765
commit
b7df26724e
|
|
@ -473,6 +473,18 @@ Country
|
|||
|
||||
<Route author="nczitzk" example="/foresightnews" path="/foresightnews"/>
|
||||
|
||||
### 文章
|
||||
|
||||
<Route author="nczitzk" example="/foresightnews/article" path="/foresightnews/article">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
**文章** 来自 **首页** 时间流,并筛除 **首页** 时间流中的 **快讯** 获得,所以 `limit` 参数不能按预期返回指定数目的文章。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
### 快讯
|
||||
|
||||
<Route author="nczitzk" example="/foresightnews/news" path="/foresightnews/news"/>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,14 @@ const cheerio = require('cheerio');
|
|||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const categories = {
|
||||
article: {
|
||||
'': {
|
||||
id: 'feed',
|
||||
title: '首页',
|
||||
},
|
||||
article: {
|
||||
id: 'feed',
|
||||
title: '文章',
|
||||
},
|
||||
news: {
|
||||
id: 'news',
|
||||
title: '快讯',
|
||||
|
|
@ -18,7 +22,7 @@ const categories = {
|
|||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'article';
|
||||
const category = ctx.params.category ?? '';
|
||||
const id = ctx.params.id ?? '1';
|
||||
|
||||
const rootUrl = 'https://foresightnews.pro';
|
||||
|
|
@ -51,6 +55,10 @@ module.exports = async (ctx) => {
|
|||
}
|
||||
);
|
||||
|
||||
if (category === 'article') {
|
||||
items = items.filter((item) => item.type === 'article');
|
||||
}
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
module.exports = {
|
||||
'/': ['nczitzk'],
|
||||
'/article': ['nczitzk'],
|
||||
'/column/:id': ['nczitzk'],
|
||||
'/news': ['nczitzk'],
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@ module.exports = {
|
|||
title: '首页',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#foresight-news-shou-ye',
|
||||
source: ['/article', '/'],
|
||||
target: '/foresightnews',
|
||||
},
|
||||
{
|
||||
title: '文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#foresight-news-wen-zhang',
|
||||
source: ['/article', '/'],
|
||||
target: '/foresightnews/article',
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue