fix(route): 知乎 收藏夹 (#7058)
This commit is contained in:
parent
4e52a65ed0
commit
84def4fe5d
|
|
@ -1,6 +1,7 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const utils = require('./utils');
|
||||
const { generateData } = require('./pin/utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
|
@ -30,17 +31,22 @@ module.exports = async (ctx) => {
|
|||
const collection_title = $('.CollectionDetailPageHeader-title').text() + ' - 知乎收藏夹';
|
||||
const collection_description = $('.CollectionDetailPageHeader-description').text();
|
||||
|
||||
const generateDataPin = (item) => generateData([item.content])[0];
|
||||
ctx.state.data = {
|
||||
title: `${collection_title}`,
|
||||
link: `https://www.zhihu.com/collection/${id}`,
|
||||
description: `${collection_description}`,
|
||||
item:
|
||||
list &&
|
||||
list.map((item) => ({
|
||||
title: `${item.content.type === 'article' ? item.content.title : item.content.question.title}`,
|
||||
link: `${item.content.url}`,
|
||||
description: `${item.content.content}`,
|
||||
pubDate: new Date((item.content.type === 'article' ? item.content.updated : item.content.updated_time) * 1000).toUTCString(),
|
||||
})),
|
||||
list.map((item) =>
|
||||
item.content.type === 'pin'
|
||||
? generateDataPin(item)
|
||||
: {
|
||||
title: `${item.content.type === 'article' ? item.content.title : item.content.question.title}`,
|
||||
link: `${item.content.url}`,
|
||||
description: `${item.content.content}`,
|
||||
pubDate: new Date((item.content.type === 'article' ? item.content.updated : item.content.updated_time) * 1000).toUTCString(),
|
||||
}
|
||||
),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue