Merge pull request #92 from DerekTso/master

update zhihu activities features
This commit is contained in:
DIYgod 2018-05-08 23:11:03 +08:00 committed by GitHub
commit f2ce082f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 2 deletions

View File

@ -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(`<p><img referrerpolicy="no-referrer" src="${contentItem.url.replace('xl', 'r')}"/></p>`);
}
})
description = `<p>${text}</p>${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 = `<p>${detail.intro}</p><p><img referrerpolicy="no-referrer" src="${detail.imageUrl}"/></p>`;
url = `${detail.url}`;
break;
}
return {
@ -65,4 +79,4 @@ module.exports = async (ctx) => {
};
}),
});
};
};