From e647abc4aaa036ff0fa7e2ec23d70f092981b73d Mon Sep 17 00:00:00 2001 From: DerekCao Date: Tue, 8 May 2018 22:59:05 +0800 Subject: [PATCH] update zhihu activities features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: 1. add images of 知乎想法 2. fix issue "关注了专栏: undefined" --- routes/zhihu/activities.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/routes/zhihu/activities.js b/routes/zhihu/activities.js index 055c13e49..e1f9e0867 100644 --- a/routes/zhihu/activities.js +++ b/routes/zhihu/activities.js @@ -47,7 +47,16 @@ module.exports = async (ctx) => { break; case 'pin': title = detail.excerptTitle.length > 17 ? detail.excerptTitle.slice(0, 17) + '...' : detail.excerptTitle; - description = detail.excerptTitle; + const images = []; + let text = ""; + detail.content.forEach(contentItem => { + if (contentItem.type === "text") { + text = contentItem.ownText; + } else if (contentItem.type === "image") { + images.push(`

`); + } + }) + description = `

${text}

${images.join('')}`; url = `https://www.zhihu.com/pin/${detail.id}`; break; case 'question': @@ -55,6 +64,11 @@ module.exports = async (ctx) => { description = detail.excerpt; url = `https://www.zhihu.com/question/${detail.id}`; break; + case 'column': + title = detail.title; + description = `

${detail.intro}

`; + url = `${detail.url}`; + break; } return { @@ -65,4 +79,4 @@ module.exports = async (ctx) => { }; }), }); -}; \ No newline at end of file +};