mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
* 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>
31 lines
974 B
JavaScript
31 lines
974 B
JavaScript
const got = require('@/utils/got');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const response = await got({
|
|
method: 'post',
|
|
url: 'https://api.juejin.cn/booklet_api/v1/booklet/listbycategory',
|
|
json: { category_id: '0', cursor: '0', limit: 20 },
|
|
});
|
|
|
|
const { data } = response.data;
|
|
const items = data.map(({ base_info }) => ({
|
|
title: base_info.title,
|
|
link: `https://juejin.cn/book/${base_info.booklet_id}`,
|
|
description: `
|
|
<img src="${base_info.cover_img}"><br>
|
|
<strong>${base_info.title}</strong><br><br>
|
|
${base_info.summary}<br>
|
|
<strong>价格:</strong> ${base_info.price / 100}元
|
|
`,
|
|
pubDate: parseDate(base_info.ctime * 1000),
|
|
guid: base_info.booklet_id,
|
|
}));
|
|
|
|
ctx.state.data = {
|
|
title: '掘金小册',
|
|
link: 'https://juejin.cn/books',
|
|
item: items,
|
|
};
|
|
};
|