From 77b5ceec087f6abe0a24df5fe382a4f6fd4a1055 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Mon, 26 Oct 2020 01:16:17 +0800 Subject: [PATCH] feat: add MIT Technology Review (#5975) --- docs/en/journal.md | 21 +++++++++++++++++++++ lib/router.js | 2 ++ lib/routes/technologyreview/topic.js | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 lib/routes/technologyreview/topic.js diff --git a/docs/en/journal.md b/docs/en/journal.md index a4027b1c8..ffdf589d9 100644 --- a/docs/en/journal.md +++ b/docs/en/journal.md @@ -88,6 +88,27 @@ The parameter id in the route is the id in the URL of the user ’s Google Schol +## MIT Technology Review + + + + + +| `:category_name` | Route | +| -------- | ----- | +| humans-and-technology | /technologyreview/humans-and-technology | +| election-2020 | /technologyreview/election-2020 | +| artificial-intelligence | /technologyreview/artificial-intelligence | +| biotechnology | /technologyreview/biotechnology | +| blockchain | /technologyreview/blockchain | +| climate-change | /technologyreview/climate-change | +| computing |/technologyreview/computing | +| tech-policy | /technologyreview/tech-policy | +| silicon-valley | /technologyreview/silicon-valley| +| smart-cities | /technologyreview/smart-cities| +| space | /technologyreview/space | + + ## Nature Journal ### Latest Research diff --git a/lib/router.js b/lib/router.js index 06420e2bd..dc72a1a47 100644 --- a/lib/router.js +++ b/lib/router.js @@ -477,6 +477,8 @@ router.get('/oschina/user/:id', require('./routes/oschina/user')); router.get('/oschina/u/:id', require('./routes/oschina/u')); router.get('/oschina/topic/:topic', require('./routes/oschina/topic')); +// MIT technology review +router.get('/technologyreview/:category_name', require('./routes/technologyreview/topic')); // 安全客 router.get('/aqk/vul', require('./routes/aqk/vul')); router.get('/aqk/:category', require('./routes/aqk/category')); diff --git a/lib/routes/technologyreview/topic.js b/lib/routes/technologyreview/topic.js new file mode 100644 index 000000000..7a1770ffe --- /dev/null +++ b/lib/routes/technologyreview/topic.js @@ -0,0 +1,17 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + ctx.params.category_name = ctx.params.category_name || 'humans-and-technology'; + + const response = await got.get(`https://wp.technologyreview.com/wp-json/irving/v1/data/term_archive?page=1&category_name=${ctx.params.category_name}`); + + ctx.state.data = { + title: 'Technology Review', + link: 'https://www.technologyreview.com/', + item: response.data.map((item) => ({ + title: item.config.title, + description: item.config.postDate, + link: item.config.permalink, + })), + }; +};