fix: /zhihu/zhuanlan undefined title (#6466)
This commit is contained in:
parent
387c23852d
commit
4e2b1fa38c
|
|
@ -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,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue