feat(route): 给 v2ex topics 添加 comments 字段 (#10819)
* feat(route): 给 v2ex topics 添加 comments 字段 * refactor: use parse-date
This commit is contained in:
parent
1400df76cc
commit
567df08399
|
|
@ -1,14 +1,10 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://www.v2ex.com/api/topics/${type}.json`,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const { data } = await got(`https://www.v2ex.com/api/topics/${type}.json`);
|
||||
|
||||
let title;
|
||||
if (type === 'hot') {
|
||||
|
|
@ -25,10 +21,10 @@ module.exports = async (ctx) => {
|
|||
title: item.title,
|
||||
description: `${item.member.username}: ${item.content_rendered}`,
|
||||
content: { text: item.content, html: item.content_rendered },
|
||||
pubDate: new Date(item.created * 1000).toUTCString(),
|
||||
guid: item.id,
|
||||
pubDate: parseDate(item.created, 'X'),
|
||||
link: item.url,
|
||||
author: item.member.username,
|
||||
comments: item.replies,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue