From 8cc0dfa231fc4ec02c3d9930d3bfaa6ed27d806b Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Wed, 6 Jan 2021 15:49:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=80=E9=98=85(simpread)=20notice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/program-update.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/simpread/notice.js | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 lib/routes/simpread/notice.js diff --git a/docs/program-update.md b/docs/program-update.md index 5cddf1086a..a2dafca86a 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -433,3 +433,9 @@ pageClass: routes | | -commentCount | -createdAt | createdAt | + +## simpread + +### 消息通知 + + diff --git a/lib/router.js b/lib/router.js index 5bb0f656c3..e9f57e3871 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3780,4 +3780,7 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog')); // Caixin Latest router.get('/caixin/latest', require('./routes/caixin/latest')); +// SimpRead +router.get('/simpread/notice', require('./routes/simpread/notice')); + module.exports = router; diff --git a/lib/routes/simpread/notice.js b/lib/routes/simpread/notice.js new file mode 100644 index 0000000000..a6ef1a11dd --- /dev/null +++ b/lib/routes/simpread/notice.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); +const md = require('markdown-it')(); + +module.exports = async (ctx) => { + const url = 'https://static.simp.red/notice'; + const response = await got.get(url); + const data = response.data.notice; + ctx.state.data = { + title: 'SimpRead 消息通知', + link: url, + description: 'SimpRead 消息通知', + item: data.map((item) => ({ + description: md.render(item.content), + link: url, + pubDate: item.date, + title: `${item.category.name}-${item.title}`, + author: 'SimpRead', + })), + }; +};