Files
RSSHub/lib/v2/woshipm/popular.js
Tony 3d9079b689 fix(route): woshipm (#11669)
* fix(route): woshipm

* fix: remove used id
2023-01-23 02:14:51 +08:00

34 lines
1008 B
JavaScript

const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { baseUrl, parseArticle } = require('./utils');
const rangeMap = {
daily: '日榜',
weekly: '周榜',
monthly: '月榜',
};
module.exports = async (ctx) => {
const { range = 'daily' } = ctx.params;
const { data: response } = await got(`${baseUrl}/api2/app/article/popular/${range}`);
const list = response.RESULT.map((item) => {
item = item.data;
return {
title: item.articleTitle,
description: item.articleSummary,
link: `${baseUrl}/${item.type}/${item.id}.html`,
pubDate: parseDate(item.publishTime, 'x'),
author: item.articleAuthor,
};
});
const result = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
ctx.state.data = {
title: `热门文章 - ${rangeMap[range]} - 人人都是产品经理`,
link: baseUrl,
item: result,
};
};