diff --git a/lib/routes/zhihu/zhuanlan.js b/lib/routes/zhihu/zhuanlan.js index d3b2ae589..10437a507 100644 --- a/lib/routes/zhihu/zhuanlan.js +++ b/lib/routes/zhihu/zhuanlan.js @@ -22,12 +22,29 @@ module.exports = async (ctx) => { const item = listRes.data.data.map((item) => { const $ = cheerio.load(item.content); $('img').css('max-width', '100%'); + + let title = ''; + let link = ''; + let author = ''; + let pubDate = ''; + + if (item.type === 'answer') { + title = item.question.title; + author = item.question.author.name; + link = `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`; + pubDate = new Date(item.question.created); + } else if (item.type === 'article') { + title = item.title; + link = item.url; + author = item.author.name; + pubDate = new Date(item.created); + } return { - title: item.title, - link: item.url, + title, + link, description: $.html(), - pubDate: new Date(item.created), - author: item.author.name, + pubDate, + author, }; });