diff --git a/docs/blog.md b/docs/blog.md index 1f85a0218..485f5193a 100644 --- a/docs/blog.md +++ b/docs/blog.md @@ -317,6 +317,12 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog +## 交流岛资源网 + +### 最新文章 + + + ## 敬维博客 ### 文章 diff --git a/lib/v2/jiaoliudao/index.js b/lib/v2/jiaoliudao/index.js new file mode 100644 index 000000000..9bb9c52c3 --- /dev/null +++ b/lib/v2/jiaoliudao/index.js @@ -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, + }; +}; diff --git a/lib/v2/jiaoliudao/maintainer.js b/lib/v2/jiaoliudao/maintainer.js new file mode 100644 index 000000000..83fc5ed48 --- /dev/null +++ b/lib/v2/jiaoliudao/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['TonyRL'], +}; diff --git a/lib/v2/jiaoliudao/radar.js b/lib/v2/jiaoliudao/radar.js new file mode 100644 index 000000000..c3b2d5cd4 --- /dev/null +++ b/lib/v2/jiaoliudao/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/jiaoliudao/router.js b/lib/v2/jiaoliudao/router.js new file mode 100644 index 000000000..7e427447c --- /dev/null +++ b/lib/v2/jiaoliudao/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/', require('./index')); +};