feat(route): add huggingface zh blog (#14211)

* feat(route): add huggingface zh blog

* refactor: update
This commit is contained in:
华丽 2024-01-10 10:38:26 +08:00 committed by GitHub
parent 035fdca3b7
commit 12b409fa62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 0 deletions

View File

@ -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,
};
};

View File

@ -1,3 +1,4 @@
module.exports = {
'/blog-zh': ['zcf0508'],
'/daily-papers': ['zeyugao'],
};

View File

@ -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',
},
],
},
};

View File

@ -1,3 +1,4 @@
module.exports = (router) => {
router.get('/blog-zh', require('./blog-zh'));
router.get('/daily-papers', require('./daily-papers'));
};

View File

@ -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}