From 263f252663d37045fac23bc360d11d5a3176d8de Mon Sep 17 00:00:00 2001 From: sanmmmm Date: Tue, 30 Jul 2019 11:45:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A4=BC=E7=89=A9=E8=AF=B4=20(#2716)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: fix afdian link error * feat: 礼物说 * revoke afdian change * fix: liwushuo error link --- docs/shopping.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/liwushuo/index.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 lib/routes/liwushuo/index.js diff --git a/docs/shopping.md b/docs/shopping.md index 0ecf80ef8..e1414df0d 100644 --- a/docs/shopping.md +++ b/docs/shopping.md @@ -42,6 +42,12 @@ pageClass: routes +## 礼物说 + +### 礼物说 + + + ## 什么值得买 ::: tip 提示 diff --git a/lib/router.js b/lib/router.js index c62a6299d..8a00f22f7 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1586,4 +1586,7 @@ router.get('/nogizaka46/news', require('./routes/nogizaka46/news')); // 阿里云 router.get('/aliyun/database_month', require('./routes/aliyun/database_month')); +// 礼物说 +router.get('/liwushuo/index', require('./routes/liwushuo/index.js')); + module.exports = router; diff --git a/lib/routes/liwushuo/index.js b/lib/routes/liwushuo/index.js new file mode 100644 index 000000000..1f4eae975 --- /dev/null +++ b/lib/routes/liwushuo/index.js @@ -0,0 +1,28 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const baseUrl = 'https://www.liwushuo.com'; + const link = `${baseUrl}/api/channels/1/items`; + const res = await got(link, { + query: { + limit: 21, + }, + }); + + const item = res.data.data.items.map((item) => { + const { content_url, cover_image_url, created_at, share_msg, title } = item; + return { + title, + link: content_url, + pubDate: new Date(created_at * 1000).toUTCString(), + description: [``, share_msg].join('
'), + }; + }); + + ctx.state.data = { + title: '礼物说 - 精选', + description: '礼物说 - 精选', + link: baseUrl, + item, + }; +};