Fix DLU sort (#5631)

This commit is contained in:
SettingDust 2020-09-17 13:25:04 +08:00 committed by GitHub
parent 35edb3cb52
commit 459b54b752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -27,16 +27,19 @@ module.exports = async (ctx) => {
const $ = cheerio.load(iconv.decode(response.data, 'utf-8'));
const regex = /(\d+)\.htm/;
ctx.state.data = {
link: base_url,
title: '大连大学教务处',
item: $('td[valign="top"]>table[cellspacing="3"][width="100%"] tr')
.slice(0, 10)
.map((_, elem) => ({
link: resolve_url(base_url, $('a', elem).attr('href')),
title: $('a', elem).attr('title'),
pubDate: new Date(new Date().getFullYear() + '-' + $('[class*="timestyle"]', elem).text().replace('/', '-')).toUTCString(),
}))
.get(),
.get()
.sort((one, two) => two.link.match(regex)[1] - one.link.match(regex)[1])
.slice(0, 20),
};
};