fix(route): fix rsshub routes

cheerio(dom) is removed in cheerio v1.0.0-rc.9
This commit is contained in:
TonyRL
2022-02-04 03:45:43 +08:00
parent 3c9be07be5
commit 8f33790045
+7 -6
View File
@@ -37,14 +37,15 @@ module.exports = async (ctx) => {
const data = response.data;
const $ = cheerio.load(data);
const page = $('.page').get();
const item = $('.routeBlock').get();
return Promise.resolve({ item, type });
return { page, item, type };
})
);
const list = [];
all.forEach(({ item, type }) => {
all.forEach(({ page, item, type }) => {
item.forEach((item) => {
list.push({ item, type });
list.push({ page, item, type });
});
});
@@ -52,9 +53,9 @@ module.exports = async (ctx) => {
title: 'RSSHub 有新路由啦',
link: 'https://docs.rsshub.app',
description: '万物皆可 RSS',
item: list.map(({ item, type }) => {
item = cheerio(item);
item.find('.header-anchor').remove();
item: list.map(({ page, item, type }) => {
const $ = cheerio.load(page);
item = $(item);
const titleEle = item.prevAll('h2').eq(0);
return {
title: `${titleEle.text().slice(2)} - ${item.prevAll('h3').eq(0).text().slice(2)}`,