fix: d2/daily pubDate and title, close #1615 (#1617)

close #1615
This commit is contained in:
WenryXu
2019-02-25 11:48:23 +08:00
committed by DIYgod
parent bdfd89aa56
commit a79d5d3eee
+7 -2
View File
@@ -16,7 +16,12 @@ module.exports = async (ctx) => {
const promises = days.map(async (ele) => {
ele = $(ele);
const relativePath = ele.attr('href');
const innerText = ele.text();
const innerText = ele
.text()
.replace(/\s+/g, '')
.replace(/年/g, '-')
.replace(/月/g, '-')
.replace(/日/g, '');
const link = url.resolve(indexLink, relativePath);
const cache = await ctx.cache.get(link);
if (cache) {
@@ -37,7 +42,7 @@ module.exports = async (ctx) => {
allowedTags: ['div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'li', 'p', 'span', 'a', 'blockquote'],
});
const item = {
title: $('head>title').text(),
title: ele.text() + ' | D2 日报',
pubDate: new Date(innerText.trim()).toUTCString(),
description,
guid: link,