mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 12:21:31 +08:00
fix(route): github trending (#12320)
This commit is contained in:
@@ -11,7 +11,7 @@ module.exports = {
|
||||
'/starred_repos/:user': ['LanceZhu'],
|
||||
'/stars/:user/:repo': ['HenryQW'],
|
||||
'/topics/:name/:qs?': ['queensferryme'],
|
||||
'/trending/:since/:language?/:spoken_language?': ['DIYgod', 'jameschensmith'],
|
||||
'/trending/:since/:language/:spoken_language?': ['DIYgod', 'jameschensmith'],
|
||||
'/user/followers/:user': ['HenryQW'],
|
||||
'/wiki/:user/:repo/:page?': ['TonyRL'],
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.github || !config.github.access_token) {
|
||||
throw 'GitHub trending RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
|
||||
throw Error('GitHub trending RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
|
||||
}
|
||||
const since = ctx.params.since;
|
||||
const language = ctx.params.language === 'any' ? '' : ctx.params.language;
|
||||
@@ -23,15 +23,13 @@ module.exports = async (ctx) => {
|
||||
const $ = cheerio.load(trendingPage);
|
||||
|
||||
const articles = $('article');
|
||||
const trendingRepos = articles
|
||||
.map((_, item) => {
|
||||
const [owner, name] = $(item).find('h1').text().split('/');
|
||||
const trendingRepos = articles.toArray().map((item) => {
|
||||
const [owner, name] = $(item).find('h2').text().split('/');
|
||||
return {
|
||||
name: name.trim(),
|
||||
owner: owner.trim(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
});
|
||||
|
||||
const { data: repoData } = await got({
|
||||
method: 'post',
|
||||
|
||||
Reference in New Issue
Block a user