diff --git a/lib/v2/hicairo/maintainer.js b/lib/v2/hicairo/maintainer.js new file mode 100644 index 0000000000..387d961bfe --- /dev/null +++ b/lib/v2/hicairo/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['cnkmmk'], +}; diff --git a/lib/v2/hicairo/radar.js b/lib/v2/hicairo/radar.js new file mode 100644 index 0000000000..19ea0e6c4c --- /dev/null +++ b/lib/v2/hicairo/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'hicairo.com': { + _name: "HiFeng'Blog", + '.': [ + { + title: '博客', + docs: 'https://docs.rsshub.app/routes/blog#hifeng-blog', + source: ['/'], + target: '/hicairo', + }, + ], + }, +}; diff --git a/lib/v2/hicairo/router.js b/lib/v2/hicairo/router.js new file mode 100644 index 0000000000..574929e02f --- /dev/null +++ b/lib/v2/hicairo/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./rss')); +}; diff --git a/lib/v2/hicairo/rss.js b/lib/v2/hicairo/rss.js new file mode 100644 index 0000000000..46d8556d60 --- /dev/null +++ b/lib/v2/hicairo/rss.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const currentUrl = 'https://www.hicairo.com'; + const response = await got(`${currentUrl}/feed.php`); + const $ = cheerio.load(response.data, { xmlMode: true }); + const title_main = $('channel > title').text(); + const description_main = $('channel > description').text(); + const items = $('channel > item') + .map((_, item) => { + const $item = $(item); + const link = $item.find('link').text(); + const title = $item.find('title').text(); + const description = $item.find('description').text(); + const pubDate = $item.find('pubDate').text(); + return { + link, + pubDate, // no need to normalize because it's from a valid RSS feed + title, + description, + }; + }) + .get(); + + ctx.state.data = { + title: title_main, + description: description_main, + link: currentUrl, + item: items, + }; +}; diff --git a/website/docs/routes/blog.mdx b/website/docs/routes/blog.mdx index 89f06df19a..b2b019e738 100644 --- a/website/docs/routes/blog.mdx +++ b/website/docs/routes/blog.mdx @@ -473,3 +473,9 @@ ### 上周热门 TOP 20 {#zhu-bai-shang-zhou-re-men-top-20} + +## HiFeng'Blog {#Hi-Feng-Blog} + +### 博客 {#Hi-Feng-Blog-bo-ke} + + \ No newline at end of file