From f867ada76f0f7f10e105b08ab1ab6691cedb588b Mon Sep 17 00:00:00 2001 From: Elsa Granger Date: Sat, 17 Feb 2024 23:17:53 +0800 Subject: [PATCH] feat(route): Support sortby upvotes in Huggingface Daily Papers (#14484) * Support sortby upvotes in Huggingface Daily Papers * Revert "Support sortby upvotes in Huggingface Daily Papers" This reverts commit 6e43f8e8a260d44b0b35f38a1af7d38eef2ffc3c. * Only sort by upvotes --------- --- lib/v2/huggingface/daily-papers.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/v2/huggingface/daily-papers.js b/lib/v2/huggingface/daily-papers.js index af9fb54136..53bbafe36c 100644 --- a/lib/v2/huggingface/daily-papers.js +++ b/lib/v2/huggingface/daily-papers.js @@ -7,13 +7,16 @@ module.exports = async (ctx) => { const $ = cheerio.load(response); const papers = $('main > div[data-target="DailyPapers"]').data('props'); - const items = papers.dailyPapers.map((item) => ({ - title: item.title, - link: `https://arxiv.org/abs/${item.paper.id}`, - description: item.paper.summary.replaceAll('\n', ' '), - pubDate: parseDate(item.publishedAt), - author: item.paper.authors.map((author) => author.name).join(', '), - })); + const items = papers.dailyPapers + .map((item) => ({ + title: item.title, + link: `https://arxiv.org/abs/${item.paper.id}`, + description: item.paper.summary.replaceAll('\n', ' '), + pubDate: parseDate(item.publishedAt), + author: item.paper.authors.map((author) => author.name).join(', '), + upvotes: item.paper.upvotes, + })) + .sort((a, b) => b.upvotes - a.upvotes); ctx.state.data = { title: 'Huggingface Daily Papers',