diff --git a/docs/new-media.md b/docs/new-media.md index f1e863f126..a9321d41a9 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -417,6 +417,12 @@ pageClass: routes +## 快知 + +### 话题 + + + ## 老司机 ### 首页 diff --git a/lib/router.js b/lib/router.js index 529bf8ed80..00bcc43155 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1783,6 +1783,9 @@ router.get('/watchface/:watch_type?/:list_type?', require('./routes/watchface/up router.get('/cnu/selected', require('./routes/cnu/selected')); router.get('/cnu/discovery/:type?/:category?', require('./routes/cnu/discovery')); +// 快知 +router.get('/kzfeed/topic/:id', require('./routes/kzfeed/topic')); + // 腾讯新闻较真查证平台 router.get('/factcheck', require('./routes/tencent/factcheck')); diff --git a/lib/routes/kzfeed/topic.js b/lib/routes/kzfeed/topic.js new file mode 100644 index 0000000000..d2c1dd910a --- /dev/null +++ b/lib/routes/kzfeed/topic.js @@ -0,0 +1,46 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const info_res = await got({ + method: 'post', + url: 'https://kz.sync163.com/api/topic/info', + headers: { + from: 'h5', + token: 'asdfasdfasdf', + 'Content-Type': 'application/json', + }, + data: JSON.stringify({ + topic_id: id, + }), + }); + const info = info_res.data; + + const cards_res = await got({ + method: 'post', + url: 'https://kz.sync163.com/api/topic/cards', + headers: { + from: 'h5', + token: 'asdfasdfasdf', + 'Content-Type': 'application/json', + }, + data: JSON.stringify({ + topic_id: id, + }), + }); + const list = cards_res.data.list; + + ctx.state.data = { + title: `快知 - ${info.info.name}`, + description: info.info.description, + link: `https://kz.sync163.com/web/topic/${id}`, + image: info.info.icon, + item: list.map((item) => ({ + title: item.title ? item.title : item.url_title, + description: `

${item.text}

${item.url_desc}…

`, + pubDate: new Date(item.created_time * 1000), + link: item.url, + })), + }; +};