Files
RSSHub/lib/v2/juejin/posts.js
CancerGary 950bfa61ed feat(route): add juejin news (#7969)
* feat(route): add juejin news

* feat(route): add juejin news

* fix(route): juejin news pubDate

* fix: fix utility

* refactor: migrate to v2

* fix: typo

Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
2022-05-20 01:55:18 +08:00

26 lines
753 B
JavaScript

const got = require('@/utils/got');
const util = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
const response = await got({
method: 'post',
url: 'https://api.juejin.cn/content_api/v1/article/query_list',
json: {
user_id: id,
sort_type: 2,
},
});
const { data } = response.data;
const username = data[0] && data[0].author_user_info && data[0].author_user_info.user_name;
const resultItems = await util.ProcessFeed(data, ctx.cache);
ctx.state.data = {
title: `掘金专栏-${username}`,
link: `https://juejin.cn/user/${id}/posts`,
description: `掘金专栏-${username}`,
item: resultItems,
};
};