fix: handle wemp future pubDate (#1546)

This commit is contained in:
Henry Wang
2019-02-19 03:26:40 +00:00
committed by DIYgod
parent de74c26136
commit 44189d5261

View File

@@ -16,23 +16,32 @@ module.exports = async (ctx) => {
const items = $('.post-item__main')
.slice(0, 10)
.get()
.map((e) => ({
title: $(e)
.find('.post-item__title')
.text()
.trim(),
link: `https://wemp.app${$(e)
.find('.post-item__title')
.attr('href')}`,
pubDate: date(
.map((e) => {
let pubDate = date(
`${year} ${$(e)
.find('.post-item__date')
.text()
.trim()}`,
8
),
author,
}));
);
if (new Date(pubDate) > new Date()) {
pubDate = new Date(pubDate).setFullYear(year - 1);
pubDate = new Date(pubDate).toUTCString();
}
return {
title: $(e)
.find('.post-item__title')
.text()
.trim(),
link: `https://wemp.app${$(e)
.find('.post-item__title')
.attr('href')}`,
pubDate,
author,
};
});
ctx.state.data = {
title: `微信公众号 - ${author}`,