This commit is contained in:
周长安
2019-01-31 11:46:05 +08:00
committed by DIYgod
parent 0a62389eaa
commit 196220868d
+4 -2
View File
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
const relativePath = ele.attr('href');
const innerText = ele.text();
const link = url.resolve(indexLink, relativePath);
const cache = ctx.cache.get(link);
const cache = await ctx.cache.get(link);
if (cache) {
return cache;
}
@@ -32,13 +32,15 @@ module.exports = async (ctx) => {
description = sanitizeHtml(description, {
allowedTags: ['section', 'h2', 'ul', 'li', 'p', 'span', 'a'],
});
return {
const item = {
title: $('head>title').text(),
pubDate: new Date(innerText.trim()).toUTCString(),
description,
guid: link,
link,
};
await ctx.cache.set(link, cache, 24 * 60 * 60);
return item;
});
ctx.state.data = {