From 4e9b596e813cac6a4c6519184e1b54a2a2d7ae3f Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 5 Sep 2022 12:21:56 -0500 Subject: [PATCH] feat(route): rarehistoricalphotos (#10707) --- docs/en/picture.md | 9 ++++++++ lib/v2/rarehistoricalphotos/index.js | 28 +++++++++++++++++++++++ lib/v2/rarehistoricalphotos/maintainer.js | 3 +++ lib/v2/rarehistoricalphotos/radar.js | 13 +++++++++++ lib/v2/rarehistoricalphotos/router.js | 3 +++ 5 files changed, 56 insertions(+) create mode 100644 lib/v2/rarehistoricalphotos/index.js create mode 100644 lib/v2/rarehistoricalphotos/maintainer.js create mode 100644 lib/v2/rarehistoricalphotos/radar.js create mode 100644 lib/v2/rarehistoricalphotos/router.js diff --git a/docs/en/picture.md b/docs/en/picture.md index cbeb535b1..0f5b1bcc2 100644 --- a/docs/en/picture.md +++ b/docs/en/picture.md @@ -234,17 +234,26 @@ For example: +## Rare Historical Photos + +### Home + + + ## Tits Guru ### Home + ### Daily Best + ### Models + ### Categories diff --git a/lib/v2/rarehistoricalphotos/index.js b/lib/v2/rarehistoricalphotos/index.js new file mode 100644 index 000000000..c95f91c56 --- /dev/null +++ b/lib/v2/rarehistoricalphotos/index.js @@ -0,0 +1,28 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +const baseUrl = 'https://rarehistoricalphotos.com'; + +module.exports = async (ctx) => { + const { data } = await got(`${baseUrl}/wp-json/wp/v2/posts`, { + searchParams: { + per_page: ctx.query.limit ? Number(ctx.query.limit) : undefined, + }, + }); + + const items = data.map((item) => ({ + title: item.title.rendered, + description: item.content.rendered, + link: item.link, + pubDate: parseDate(item.date_gmt), + })); + + ctx.state.data = { + title: 'Rare Historical Photos', + description: 'And the story behind them...', + link: baseUrl, + image: 'https://rarehistoricalphotos.com/wp-content/uploads/2022/04/cropped-rarehistoricalphotos-32x32.png', + language: 'en-US', + item: items, + }; +}; diff --git a/lib/v2/rarehistoricalphotos/maintainer.js b/lib/v2/rarehistoricalphotos/maintainer.js new file mode 100644 index 000000000..83fc5ed48 --- /dev/null +++ b/lib/v2/rarehistoricalphotos/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['TonyRL'], +}; diff --git a/lib/v2/rarehistoricalphotos/radar.js b/lib/v2/rarehistoricalphotos/radar.js new file mode 100644 index 000000000..953b05c03 --- /dev/null +++ b/lib/v2/rarehistoricalphotos/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'rarehistoricalphotos.com': { + _name: 'Rare Historical Photos', + '.': [ + { + title: 'Home', + docs: 'https://docs.rsshub.app/en/picture.html#rare-historical-photos', + source: ['/'], + target: '/rarehistoricalphotos', + }, + ], + }, +}; diff --git a/lib/v2/rarehistoricalphotos/router.js b/lib/v2/rarehistoricalphotos/router.js new file mode 100644 index 000000000..7e427447c --- /dev/null +++ b/lib/v2/rarehistoricalphotos/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/', require('./index')); +};