From 04b47eff53dc724c0dd60858233efad790aa8d79 Mon Sep 17 00:00:00 2001 From: iClaud Date: Wed, 8 Nov 2023 00:43:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20Add=20=E7=A6=8F=E5=88=A9?= =?UTF-8?q?=E5=90=A7=E6=9C=80=E8=BF=91=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9?= =?UTF-8?q?=20(#13711)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fuliba added * style: auto format * doc refine for fuliba * update per lint info * fix some title and style * update per SSRF concern comment * update per SSRF concern during review * Update lib/v2/fuliba/radar.js Per comment on naming of title * Update website/docs/routes/new-media.mdx * turn to wordpress api * Update website/docs/routes/new-media.mdx --------- Co-authored-by: shinemoon Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/v2/fuliba/latest.js | 25 +++++++++++++++++++++++++ lib/v2/fuliba/maintainer.js | 3 +++ lib/v2/fuliba/radar.js | 15 +++++++++++++++ lib/v2/fuliba/router.js | 3 +++ website/docs/routes/new-media.mdx | 6 ++++++ 5 files changed, 52 insertions(+) create mode 100644 lib/v2/fuliba/latest.js create mode 100644 lib/v2/fuliba/maintainer.js create mode 100644 lib/v2/fuliba/radar.js create mode 100644 lib/v2/fuliba/router.js diff --git a/lib/v2/fuliba/latest.js b/lib/v2/fuliba/latest.js new file mode 100644 index 000000000..0bb1ea126 --- /dev/null +++ b/lib/v2/fuliba/latest.js @@ -0,0 +1,25 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { data: response } = await got(`https://fuliba2023.net/wp-json/wp/v2/posts`, { + searchParams: { + per_page: ctx.query.limit ?? 100, + _embed: 1, + }, + }); + const items = response.map((item) => ({ + title: item.title.rendered, + link: item.link, + guid: item.guid.rendered, + description: item.content.rendered, + pubDate: parseDate(item.date_gmt), + author: item._embedded.author[0].name, + })); + + ctx.state.data = { + title: '福利吧', + link: `https://fuliba2023.net`, + item: items, + }; +}; diff --git a/lib/v2/fuliba/maintainer.js b/lib/v2/fuliba/maintainer.js new file mode 100644 index 000000000..b2e264a5b --- /dev/null +++ b/lib/v2/fuliba/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/latest': ['shinemoon'], +}; diff --git a/lib/v2/fuliba/radar.js b/lib/v2/fuliba/radar.js new file mode 100644 index 000000000..5868a52ad --- /dev/null +++ b/lib/v2/fuliba/radar.js @@ -0,0 +1,15 @@ +const fuliba = { + _name: '福利吧', + '.': [ + { + title: '最新', + docs: 'https://docs.rsshub.app/routes/new-media#fuliba', + source: '/', + target: '/fuliba/latest', + }, + ], +}; + +module.exports = { + 'fuliba2023.net': fuliba, +}; diff --git a/lib/v2/fuliba/router.js b/lib/v2/fuliba/router.js new file mode 100644 index 000000000..f70796a86 --- /dev/null +++ b/lib/v2/fuliba/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/latest', require('./latest')); +}; diff --git a/website/docs/routes/new-media.mdx b/website/docs/routes/new-media.mdx index c94ca05d0..189025c53 100644 --- a/website/docs/routes/new-media.mdx +++ b/website/docs/routes/new-media.mdx @@ -3293,6 +3293,12 @@ Type 栏目: +## 福利吧 {#fu-li-ba} + +### 最新 {#fu-li-ba-zui-xin} + + + ## 福利年 {#fu-li-nian} ### 文章 {#fu-li-nian-wen-zhang}