feat(route): jiaoliudao (#11821)

This commit is contained in:
Tony 2023-02-09 09:51:12 -06:00 committed by GitHub
parent 28d1703bd7
commit 4bb4245f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 0 deletions

View File

@ -317,6 +317,12 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog
</Route>
## 交流岛资源网
### 最新文章
<Route author="TonyRL" example="/jiaoliudao" path="/jiaoliudao" radar="1">
## 敬维博客
### 文章

View File

@ -0,0 +1,35 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const baseUrl = 'https://www.jiaoliudao.com';
module.exports = async (ctx) => {
const { data } = await got(`${baseUrl}/wp-json/wp/v2/posts`, {
searchParams: {
per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 100,
},
});
const items = data.map((item) => {
const $ = cheerio.load(item.content.rendered, null, false);
$('img').each((_, img) => {
if (img.attribs['data-original']) {
img.attribs.src = img.attribs['data-original'];
delete img.attribs['data-original'];
}
});
return {
title: item.title.rendered,
description: $.html(),
pubDate: parseDate(item.date_gmt),
link: item.link,
};
});
ctx.state.data = {
title: '交流岛资源网-专注网络资源收集',
image: `${baseUrl}/favicon.ico`,
link: baseUrl,
item: items,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/': ['TonyRL'],
};

View File

@ -0,0 +1,13 @@
module.exports = {
'jiaoliudao.com': {
_name: '交流岛资源网',
'.': [
{
title: '最新文章',
docs: 'https://docs.rsshub.app/blog.html#jiao-liu-dao-zi-yuan-wang',
source: ['/'],
target: '/jiaoliudao',
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/', require('./index'));
};