mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
fix(route): github trending (#12320)
This commit is contained in:
@@ -11,7 +11,7 @@ module.exports = {
|
|||||||
'/starred_repos/:user': ['LanceZhu'],
|
'/starred_repos/:user': ['LanceZhu'],
|
||||||
'/stars/:user/:repo': ['HenryQW'],
|
'/stars/:user/:repo': ['HenryQW'],
|
||||||
'/topics/:name/:qs?': ['queensferryme'],
|
'/topics/:name/:qs?': ['queensferryme'],
|
||||||
'/trending/:since/:language?/:spoken_language?': ['DIYgod', 'jameschensmith'],
|
'/trending/:since/:language/:spoken_language?': ['DIYgod', 'jameschensmith'],
|
||||||
'/user/followers/:user': ['HenryQW'],
|
'/user/followers/:user': ['HenryQW'],
|
||||||
'/wiki/:user/:repo/:page?': ['TonyRL'],
|
'/wiki/:user/:repo/:page?': ['TonyRL'],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const path = require('path');
|
|||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
if (!config.github || !config.github.access_token) {
|
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 since = ctx.params.since;
|
||||||
const language = ctx.params.language === 'any' ? '' : ctx.params.language;
|
const language = ctx.params.language === 'any' ? '' : ctx.params.language;
|
||||||
@@ -23,15 +23,13 @@ module.exports = async (ctx) => {
|
|||||||
const $ = cheerio.load(trendingPage);
|
const $ = cheerio.load(trendingPage);
|
||||||
|
|
||||||
const articles = $('article');
|
const articles = $('article');
|
||||||
const trendingRepos = articles
|
const trendingRepos = articles.toArray().map((item) => {
|
||||||
.map((_, item) => {
|
const [owner, name] = $(item).find('h2').text().split('/');
|
||||||
const [owner, name] = $(item).find('h1').text().split('/');
|
|
||||||
return {
|
return {
|
||||||
name: name.trim(),
|
name: name.trim(),
|
||||||
owner: owner.trim(),
|
owner: owner.trim(),
|
||||||
};
|
};
|
||||||
})
|
});
|
||||||
.get();
|
|
||||||
|
|
||||||
const { data: repoData } = await got({
|
const { data: repoData } = await got({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|||||||
Reference in New Issue
Block a user