Files
RSSHub/lib/v2/usepanda/index.js
lyrl f796ff1d54 feat(route): add panda feed (#11367)
* * feat: add panda feed

* * feat: document table inside the Route tag

* * feat: panda route Introduce limit parameter

* docs(ROUTE): add /panda/feeds/:id  parameter description

* refactor(ROUTE): Use a more appropriate path  /usepanda/feeds/:id   instead of  /panda/feeds/:id

* refactor(ROUTE): Remove non-existent attributes tags

* feat(ROUTE): fix limit param

* fix: add missing radar
2022-12-05 23:24:21 +08:00

27 lines
799 B
JavaScript

const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const feedId = ctx.params.id;
const limit = ctx.query.limit ?? 30; // 默认30条
const rootUrl = 'https://api-panda.com/v4/';
const apiUrl = `${rootUrl}articles?feeds=${feedId}&limit=${limit}&page=1&sort=popular`;
const { data } = await got(apiUrl);
const items = data.map((item) => ({
title: `${item.title} 🌟 ${item.source.likesCount}`,
author: item.source.username,
pubDate: parseDate(item.source.createdAt),
link: item.source.targetUrl,
description: item.description,
}));
ctx.state.data = {
title: 'Panda Feeds',
link: 'https://usepanda.com/',
item: items,
};
};