feat(route): add huggingface zh blog (#14211)
* feat(route): add huggingface zh blog * refactor: update
This commit is contained in:
parent
035fdca3b7
commit
12b409fa62
|
|
@ -0,0 +1,34 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { body: response } = await got('https://huggingface.co/blog/zh');
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
/** @type {Array<{blog: {local: string, title: string, author: string, thumbnail: string, date: string, tags: Array<string>}, blogUrl: string, lang: 'zh', link: string}>} */
|
||||
const papers = $('div[data-target="BlogThumbnail"]')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
const props = $(item).data('props');
|
||||
const link = $(item).find('a').attr('href');
|
||||
return {
|
||||
...props,
|
||||
link,
|
||||
};
|
||||
});
|
||||
|
||||
const items = papers.map((item) => ({
|
||||
title: item.blog.title,
|
||||
link: `https://huggingface.co${item.link}`,
|
||||
category: item.blog.tags,
|
||||
pubDate: parseDate(item.blog.date),
|
||||
author: item.blog.author,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Huggingface 中文博客',
|
||||
link: 'https://huggingface.co/blog/zh',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = {
|
||||
'/blog-zh': ['zcf0508'],
|
||||
'/daily-papers': ['zeyugao'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@ module.exports = {
|
|||
source: ['/papers', '/'],
|
||||
target: '/huggingface/daily-papers',
|
||||
},
|
||||
{
|
||||
title: '中文博客',
|
||||
docs: 'https://docs.rsshub.app/routes/programming#huggingface',
|
||||
source: ['/blog/zh', '/'],
|
||||
target: '/huggingface/blog-zh',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/blog-zh', require('./blog-zh'));
|
||||
router.get('/daily-papers', require('./daily-papers'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -492,6 +492,10 @@ Subscribe to the updates (threads and submission) from a paritcular Hacker News
|
|||
|
||||
<Route author="zeyugao" example="/huggingface/daily-papers" path="/huggingface/daily-papers" />
|
||||
|
||||
### 中文博客 {#huggingface-zhong-wen-bo-ke}
|
||||
|
||||
<Route author="zcf0508" example="/huggingface/blog-zh" path="/huggingface/blog-zh" />
|
||||
|
||||
## Issue Hunt {#issue-hunt}
|
||||
|
||||
### Project Funded {#issue-hunt-project-funded}
|
||||
|
|
|
|||
Loading…
Reference in New Issue