mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
Support sortby upvotes in Huggingface Daily Papers
This commit is contained in:
@@ -4,17 +4,23 @@ const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { body: response } = await got('https://huggingface.co/papers');
|
||||
const sortby = ctx.params.sortby || 'time';
|
||||
const $ = cheerio.load(response);
|
||||
const papers = $('main > div[data-target="DailyPapers"]').data('props');
|
||||
|
||||
const items = papers.dailyPapers.map((item) => ({
|
||||
let 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),
|
||||
pubDate: sortby === 'time' ? parseDate(item.publishedAt) : undefined,
|
||||
author: item.paper.authors.map((author) => author.name).join(', '),
|
||||
upvotes: item.paper.upvotes,
|
||||
}));
|
||||
|
||||
if (sortby === 'votes') {
|
||||
items = items.sort((a, b) => b.upvotes - a.upvotes);
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Huggingface Daily Papers',
|
||||
link: 'https://huggingface.co/papers',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/blog-zh', require('./blog-zh'));
|
||||
router.get('/daily-papers', require('./daily-papers'));
|
||||
router.get('/daily-papers/:sortby?', require('./daily-papers'));
|
||||
};
|
||||
|
||||
@@ -490,7 +490,11 @@ Subscribe to the updates (threads and submission) from a paritcular Hacker News
|
||||
|
||||
### Daily Papers {#huggingface-daily-papers}
|
||||
|
||||
<Route author="zeyugao" example="/huggingface/daily-papers" path="/huggingface/daily-papers" />
|
||||
<Route author="zeyugao" example="/huggingface/daily-papers/time" path="/huggingface/daily-papers/:sortby?" paramsDesc={['排序方式,见下表,默认为发布时间']}>
|
||||
| 时间 | upvotes |
|
||||
| ---- | ------- |
|
||||
| time | votes |
|
||||
</Route>
|
||||
|
||||
### 中文博客 {#huggingface-zhong-wen-bo-ke}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user