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
This commit is contained in:
lyrl
2022-12-05 23:24:21 +08:00
committed by GitHub
parent 11993cb197
commit f796ff1d54
6 changed files with 67 additions and 1 deletions
+12 -1
View File
@@ -166,6 +166,18 @@ Official Website: <https://news.yahoo.co.jp/pages/article/20200207>
</RouteEn>
## Panda
### Feeds
<RouteEn author="lyrl" example="/usepanda/feeds/5718e53e7a84fb1901e059cc" path="/usepanda/feeds/:id" :paramsDesc="['Feed ID']">
| Channel | feedId |
| -------------------- | ------------------------ |
| Github | 5718e53e7a84fb1901e059cc |
</RouteEn>
## Parcel Tracking
### Hermes UK
@@ -266,4 +278,3 @@ Refer to [the list of supported currencies](https://wise.com/tools/exchange-rate
### User
<RouteEn author="SettingDust Halcao" example="/uraaka-joshi/_rrwq" path="/uraaka-joshi/:id" :paramsDesc="['User ID']" radar="1" rssbud="1" puppeteer="1"/>
+12
View File
@@ -242,6 +242,18 @@ pageClass: routes
<Route author="fengkx" example="/one" path="/one"/>
## Panda
### Feeds
<Route author="lyrl" example="/usepanda/feeds/5718e53e7a84fb1901e059cc" path="/usepanda/feeds/:id" :paramsDesc="['频道id/feedId']">
| 频道 | feedId |
| ----------- | ------------------------ |
| Github 热门推荐 | 5718e53e7a84fb1901e059cc |
</Route>
## Parcel Tracking
### Hermes UK
+26
View File
@@ -0,0 +1,26 @@
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,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/feeds/:id': ['lyrl'],
};
+11
View File
@@ -0,0 +1,11 @@
module.exports = {
'usepanda.com': {
_name: 'Panda',
'.': [
{
title: 'Feeds',
docs: 'https://docs.rsshub.app/other.html#panda',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/feeds/:id', require('./index'));
};