update zhihu activities features

updates:
1. add images of 知乎想法
2. fix issue "关注了专栏: undefined"
This commit is contained in:
DerekCao 2018-05-08 22:59:05 +08:00
parent e02217aa95
commit e647abc4aa
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) => {
};
}),
});
};
};