feat(route): jiaoliudao (#11821)
This commit is contained in:
parent
28d1703bd7
commit
4bb4245f50
|
|
@ -317,6 +317,12 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog
|
|||
|
||||
</Route>
|
||||
|
||||
## 交流岛资源网
|
||||
|
||||
### 最新文章
|
||||
|
||||
<Route author="TonyRL" example="/jiaoliudao" path="/jiaoliudao" radar="1">
|
||||
|
||||
## 敬维博客
|
||||
|
||||
### 文章
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/': ['TonyRL'],
|
||||
};
|
||||
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue