diff --git a/lib/routes/leetcode/articles.js b/lib/routes/leetcode/articles.js index 4a6679c4ba..6ed0d7b320 100644 --- a/lib/routes/leetcode/articles.js +++ b/lib/routes/leetcode/articles.js @@ -11,15 +11,21 @@ module.exports = async (ctx) => { const list = $('a.list-group-item') .slice(0, 10) + .filter((i, e) => $(e).find('h4.media-heading i').length === 0) .map(function() { const info = { title: $(this) .find('h4.media-heading') + .text() + .trim(), + author: $(this) + .find('.text-500') .text(), link: $(this).attr('href'), date: $(this) .find('p.pull-right.media-date strong') - .text(), + .text() + .trim(), }; return info; }) @@ -27,8 +33,6 @@ module.exports = async (ctx) => { const out = await Promise.all( list.map(async (info) => { - const title = info.title; - const date = info.date; const itemUrl = url.resolve(host, info.link); const cache = await ctx.cache.get(itemUrl); @@ -47,19 +51,22 @@ module.exports = async (ctx) => { .trim(); const single = { - title: title, + title: info.title, + author: info.author, link: itemUrl, - description: description, - pubDate: new Date(date).toUTCString(), + description, + pubDate: new Date(info.date).toUTCString(), }; + ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); return Promise.resolve(single); }) ); ctx.state.data = { - title: 'leetcode文章', - link: link, + title: 'LeetCode Articles', + description: 'LeetCode Articles, the only official solutions you will find.', + link, item: out, }; };