fix(route): `pubDate` for `fontstory` (#8069)

This commit is contained in:
Toby Tso 2021-09-09 16:44:28 +08:00 committed by GitHub
parent 8d46760850
commit d94894be87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -7,19 +7,20 @@ const timezone = require('@/utils/timezone');
function getArticle(ctx, list) {
const now = list.map((line) =>
ctx.cache.tryGet(line, async () => {
const a_r = await got.get(`https://www.dynacw.com.tw/fontstory/${line}`);
const $ = cheerio.load(a_r.data);
const t_r = $('h2.col-xs-12.tc-deeppink').first().text();
const articleRaw = await got.get(`https://www.dynacw.com.tw/fontstory/${line}`);
const $ = cheerio.load(articleRaw.data);
const titleRaw = $('h2.col-xs-12.tc-deeppink').first().text();
const tag = $('div.date-txt.col-xs-8.tc-gray').first().text();
const timeRaw = $('div.date-txt.col-xs-4.tc-gray.text-right');
$('main.container').find('ol.breadcrumb.hidden-xs').remove();
$('main.container').find('section.row').first().remove();
$('main.container').find('section.pages.row').remove();
const desc = $('main.container').html();
return {
title: `${t_r}${tag}`,
title: `${titleRaw}${tag}`,
description: desc,
pubDate: timezone(parseDate($('div.date-txt.col-xs-4.tc-gray.text-right').text(), 'YYYY年MM月DD日'), +8),
pubDate: timezone(parseDate(timeRaw.text(), 'YYYY年MM月DD日'), +8),
link: `https://www.dynacw.com.tw/fontstory/${line}`,
};
})