From 09c6ab2b1b50308838bfa99effd98fefb1b8756f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Mon, 15 Apr 2019 10:50:46 +0800 Subject: [PATCH] Hotifx: rsshub rss link (#1931) Closes #1915 --- lib/routes/rsshub/rss.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/routes/rsshub/rss.js b/lib/routes/rsshub/rss.js index 979a868d2..68fa7b24f 100644 --- a/lib/routes/rsshub/rss.js +++ b/lib/routes/rsshub/rss.js @@ -14,12 +14,14 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const item = $('.routeBlock').get(); - return Promise.resolve(item); + return Promise.resolve({ item, type }); }) ); - let list = []; - all.forEach((item) => { - list = list.concat(item); + const list = []; + all.forEach(({ item, type }) => { + item.forEach((item) => { + list.unshift({ item, type }); + }); }); ctx.state.data = { @@ -28,7 +30,7 @@ module.exports = async (ctx) => { description: '万物皆可 RSS', item: list && - list.reverse().map((item) => { + list.map(({ item, type }) => { item = cheerio(item); item.find('.header-anchor').remove(); const titleEle = item.prevAll('h2').eq(0); @@ -39,7 +41,7 @@ module.exports = async (ctx) => { .eq(0) .text()}`, description: item.html(), - link: `https://docs.rsshub.app#${encodeURIComponent( + link: `https://docs.rsshub.app/${type}.html#${encodeURIComponent( titleEle.find('.header-anchor').attr('href') && titleEle .find('.header-anchor')