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 6e43f8e8a2.

* Only sort by upvotes

---------
This commit is contained in:
Elsa Granger
2024-02-17 23:17:53 +08:00
committed by GitHub
parent 6cc3acde01
commit f867ada76f
+10 -7
View File
@@ -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',