From a79d5d3eee747ddbbf67ec133e704a9434e1deb0 Mon Sep 17 00:00:00 2001 From: WenryXu Date: Mon, 25 Feb 2019 11:48:23 +0800 Subject: [PATCH] fix: d2/daily pubDate and title, close #1615 (#1617) close #1615 --- lib/routes/d2/daily.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/routes/d2/daily.js b/lib/routes/d2/daily.js index 524f0260f0..569f943a6d 100644 --- a/lib/routes/d2/daily.js +++ b/lib/routes/d2/daily.js @@ -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,