From d73cf524a26e09793ffc041665460a8435cb4653 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 18 Aug 2023 19:09:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(router):=20=E5=A2=9E=E5=8A=A0=20xiaote.com?= =?UTF-8?q?=20=E8=AE=BA=E5=9D=9B=E8=B7=AF=E7=94=B1=20(#13062)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 增加 xiaote.com 论坛路由 * feat: add radar.js * feat: format code * bugfix: radar error * fix: all marge issuse --- lib/v2/xiaote/index.js | 48 +++++++++++++++++++++++++++++++++++++ lib/v2/xiaote/maintainer.js | 3 +++ lib/v2/xiaote/radar.js | 13 ++++++++++ lib/v2/xiaote/router.js | 3 +++ website/docs/routes/bbs.md | 7 ++++++ 5 files changed, 74 insertions(+) create mode 100644 lib/v2/xiaote/index.js create mode 100644 lib/v2/xiaote/maintainer.js create mode 100644 lib/v2/xiaote/radar.js create mode 100644 lib/v2/xiaote/router.js diff --git a/lib/v2/xiaote/index.js b/lib/v2/xiaote/index.js new file mode 100644 index 0000000000..9664b126ce --- /dev/null +++ b/lib/v2/xiaote/index.js @@ -0,0 +1,48 @@ +const got = require('@/utils/got'); // 自订的 got +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { data } = await got.post('https://lcen.xiaote.net//api/graphql/', { + json: { + query: `query($startCursor: Int) { + communities(startCursor: $startCursor) { + edges { + node { + objectId + content + createdAt + imageUrls + user{ + nickname + } + } + } + } + }`, + }, + }); + + ctx.state.data = { + title: '小特社区', + // 源链接 + link: 'https://xiaote.com/', + // 遍历所有此前获取的数据 + item: data.data.communities.edges.map((node) => { + const item = node.node; + let description = item.content; + if (item.imageUrls) { + item.imageUrls.forEach((url) => { + description += ``; + }); + } + + return { + title: item.content, + link: `https://www.xiaote.com/r/${item.objectId}`, + description, + pubDate: parseDate(item.createdAt * 1000), + author: item.user.nickname, + }; + }), + }; +}; diff --git a/lib/v2/xiaote/maintainer.js b/lib/v2/xiaote/maintainer.js new file mode 100644 index 0000000000..540aa0b8ff --- /dev/null +++ b/lib/v2/xiaote/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news': ['wxsimon'], +}; diff --git a/lib/v2/xiaote/radar.js b/lib/v2/xiaote/radar.js new file mode 100644 index 0000000000..bb84765709 --- /dev/null +++ b/lib/v2/xiaote/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'xiaote.com': { + _name: '小特社区', + '.': [ + { + title: '首页帖子', + docs: 'https://docs.rsshub.app/bbs#xiao-te-she-qu', + source: ['/'], + target: '/xiaote/news', + }, + ], + }, +}; diff --git a/lib/v2/xiaote/router.js b/lib/v2/xiaote/router.js new file mode 100644 index 0000000000..2c3658e804 --- /dev/null +++ b/lib/v2/xiaote/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/news', require('./index')); +}; diff --git a/website/docs/routes/bbs.md b/website/docs/routes/bbs.md index 258984a4bb..868d06dafa 100644 --- a/website/docs/routes/bbs.md +++ b/website/docs/routes/bbs.md @@ -1087,6 +1087,12 @@ import Route from '@site/src/components/Route'; +## 小特社区 {#xiao-te-she-qu} + +### 首页帖子 {#xiao-te-she-qu-shou-ye-tie-zi} + + + ## 一亩三分地 {#yi-mu-san-fen-di} ### 帖子 {#yi-mu-san-fen-di-tie-zi} @@ -1238,3 +1244,4 @@ import Route from '@site/src/components/Route'; | lingyishijain | lingyitupian | minjianqitan | +