Merge pull request #93 from DerekTso/master

add "link" type for "知乎想法"
This commit is contained in:
DIYgod 2018-05-08 23:24:25 +08:00 committed by GitHub
commit 01dbdde769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -49,14 +49,17 @@ module.exports = async (ctx) => {
title = detail.excerptTitle.length > 17 ? detail.excerptTitle.slice(0, 17) + '...' : detail.excerptTitle;
const images = [];
let text = "";
let link = "";
detail.content.forEach(contentItem => {
if (contentItem.type === "text") {
text = contentItem.ownText;
text = `<p>${contentItem.ownText}</p>`;
} else if (contentItem.type === "image") {
images.push(`<p><img referrerpolicy="no-referrer" src="${contentItem.url.replace('xl', 'r')}"/></p>`);
} else if (contentItem.type === "link") {
link = `<p><a href="${contentItem.url}" target="_blank">${contentItem.title}</a></p>`
}
})
description = `<p>${text}</p>${images.join('')}`;
description = `${text}${link}${images.join('')}`;
url = `https://www.zhihu.com/pin/${detail.id}`;
break;
case 'question':