修复 manhuagui 排序问题 (#1904)

`.chapter-list` 下有多个 `ul`,最新的 `ul` 在最后面。
This commit is contained in:
mino
2019-04-10 11:33:29 +08:00
committed by DIYgod
parent 6418a76cdc
commit 2a925ef579
+14 -4
View File
@@ -3,16 +3,26 @@ const cheerio = require('cheerio');
const axios = require('../../utils/axios');
const getChapters = ($) =>
$('.chapter-list > ul li')
.map((_, ele) => {
$('.chapter-list > ul')
.toArray()
.reverse()
.reduce(
(acc, curr) =>
acc.concat(
$(curr)
.children('li')
.toArray()
),
[]
)
.map((ele) => {
const a = $(ele).children('a');
return {
link: resolve('https://www.manhuagui.com/', a.attr('href')),
title: a.attr('title'),
num: a.find('i').text(),
};
})
.toArray();
});
module.exports = async (ctx) => {
const { id } = ctx.params;