From 1a7d07d3fcda6bf1ae8f89e61096d2860e05a9ea Mon Sep 17 00:00:00 2001 From: cnkmmk <22782790+cnkmmk@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:26:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=B8=8D=E8=89=AF?= =?UTF-8?q?=E6=9E=97=20(#14479)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加几个自己用的路由 * 创建 maintainer.js * 更新 maintainer.js * 更新 freeadaycom.js * 增加 不良林 * 更新 radar.js * style: auto format * 重新调整路径 几次PR都不通过,参照一个通过的调整了路径 * 根据要求进行了修改 * 更新 blog.mdx * 更新 blog.mdx --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/v2/bulianglin/bulianglin.js | 32 ++++++++++++++++++++++++++++++++ lib/v2/bulianglin/maintainer.js | 3 +++ lib/v2/bulianglin/radar.js | 13 +++++++++++++ lib/v2/bulianglin/router.js | 3 +++ website/docs/routes/blog.mdx | 6 ++++++ 5 files changed, 57 insertions(+) create mode 100644 lib/v2/bulianglin/bulianglin.js create mode 100644 lib/v2/bulianglin/maintainer.js create mode 100644 lib/v2/bulianglin/radar.js create mode 100644 lib/v2/bulianglin/router.js diff --git a/lib/v2/bulianglin/bulianglin.js b/lib/v2/bulianglin/bulianglin.js new file mode 100644 index 000000000..e1107eea6 --- /dev/null +++ b/lib/v2/bulianglin/bulianglin.js @@ -0,0 +1,32 @@ +const { parseDate } = require('@/utils/parse-date'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'https://bulianglin.com/'; + const response = await got({ method: 'get', url }); + const $ = cheerio.load(response.data); + + const list = $('div.single-post') + .map((i, e) => { + const element = $(e); + const title = element.find('h2 > a').text(); + const link = element.find('h2 > a').attr('href'); + const description = element.find('p.summary').text(); + const dateraw = element.find('div.text-muted').find('li').eq(1).text(); + + return { + title, + description, + link, + pubDate: parseDate(dateraw, 'YYYY 年 MM 月 DD 日'), + }; + }) + .get(); + + ctx.state.data = { + title: '不良林', + link: url, + item: list, + }; +}; diff --git a/lib/v2/bulianglin/maintainer.js b/lib/v2/bulianglin/maintainer.js new file mode 100644 index 000000000..387d961bf --- /dev/null +++ b/lib/v2/bulianglin/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['cnkmmk'], +}; diff --git a/lib/v2/bulianglin/radar.js b/lib/v2/bulianglin/radar.js new file mode 100644 index 000000000..1713bcc72 --- /dev/null +++ b/lib/v2/bulianglin/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'bulianglin.com': { + _name: '不良林', + '.': [ + { + title: '博客', + docs: 'https://docs.rsshub.app/routes/blog#bu-liang-lin', + source: ['/'], + target: '/bulianglin', + }, + ], + }, +}; diff --git a/lib/v2/bulianglin/router.js b/lib/v2/bulianglin/router.js new file mode 100644 index 000000000..ae8d80b8b --- /dev/null +++ b/lib/v2/bulianglin/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./bulianglin')); +}; diff --git a/website/docs/routes/blog.mdx b/website/docs/routes/blog.mdx index ad0e62999..78cdebcc5 100644 --- a/website/docs/routes/blog.mdx +++ b/website/docs/routes/blog.mdx @@ -276,6 +276,12 @@ +## 不良林 {#bu-liang-lin} + +### 博客 {#bu-liang-lin-bo-ke} + + + ## 财新博客 {#cai-xin-bo-ke} ### 用户博客 {#cai-xin-bo-ke-yong-hu-bo-ke}