Hotifx: rsshub rss link (#1931)

Closes #1915
This commit is contained in:
凉凉
2019-04-15 10:50:46 +08:00
committed by DIYgod
parent 8dcf273e30
commit 09c6ab2b1b

View File

@@ -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')