feat(route): add spoken_language for GitHub Trending (#8456)

This commit is contained in:
Jigsaw
2021-11-27 08:46:24 +00:00
committed by GitHub
parent 3023bd6381
commit 2024ba9108
3 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ GitHub 官方也提供了一些 RSS:
### Trending
<Route author="DIYgod" example="/github/trending/daily/javascript" path="/github/trending/:since/:language?" :paramsDesc="['时间跨度, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly) URL 中找到, 可选 daily weekly monthly', '语言, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly) URL 中找到']" radar="1" rssbud="1"/>
<Route author="DIYgod" example="/github/trending/daily/javascript/zh" path="/github/trending/:since/:language?/:spoken_language?" :paramsDesc="['时间跨度, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到, 可选 daily weekly monthly', '语言, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到', '自然语言, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到']" radar="1" rssbud="1"/>
### Topics
+1 -1
View File
@@ -278,7 +278,7 @@ router.get('/readhub/category/:category', lazyloadRouteHandler('./routes/readhub
// GitHub
router.get('/github/repos/:user', lazyloadRouteHandler('./routes/github/repos'));
router.get('/github/trending/:since/:language?', lazyloadRouteHandler('./routes/github/trending'));
router.get('/github/trending/:since/:language?/:spoken_language?', lazyloadRouteHandler('./routes/github/trending'));
router.get('/github/issue/:user/:repo/:state?/:labels?', lazyloadRouteHandler('./routes/github/issue'));
router.get('/github/pull/:user/:repo', lazyloadRouteHandler('./routes/github/pulls'));
router.get('/github/user/followers/:user', lazyloadRouteHandler('./routes/github/follower'));
+2 -1
View File
@@ -4,7 +4,8 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const since = ctx.params.since;
const language = ctx.params.language || '';
const url = `https://github.com/trending/${encodeURIComponent(language)}?since=${since}`;
const spoken_language = ctx.params.spoken_language || '';
const url = `https://github.com/trending/${encodeURIComponent(language)}?since=${since}&spoken_language_code=${spoken_language}`;
const response = await got({
method: 'get',