mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 02:58:08 +08:00
* Fix(route): fix route parameter conflict at trending.js and change to V2 * Fix(route): modify the judgment condition of language parameter * Fix(docs): Update docs/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Fix(docs): Update docs/en/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(docs/route): add author and sort routes * Fix(route): Update docs/en/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Fix(route): sort routes Co-authored-by: Tony <TonyRL@users.noreply.github.com>
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
const got = require('@/utils/got');
|
||
const config = require('@/config').value;
|
||
|
||
module.exports = async (ctx) => {
|
||
if (!config.github || !config.github.access_token) {
|
||
throw 'GitHub star RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||
}
|
||
const user = ctx.params.user;
|
||
const repo = ctx.params.repo;
|
||
|
||
const host = `https://github.com/${user}/${repo}/stargazers`;
|
||
const url = 'https://api.github.com/graphql';
|
||
|
||
const response = await got({
|
||
method: 'post',
|
||
url,
|
||
headers: {
|
||
Authorization: `bearer ${config.github.access_token}`,
|
||
},
|
||
json: {
|
||
query: `
|
||
{
|
||
repository(owner: "${user}", name: "${repo}") {
|
||
stargazers(last: 10) {
|
||
edges {
|
||
node {
|
||
login
|
||
avatarUrl
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
`,
|
||
},
|
||
});
|
||
|
||
const data = response.data.data.repository.stargazers.edges.reverse();
|
||
|
||
ctx.state.data = {
|
||
allowEmpty: true,
|
||
title: `${user}/${repo}’s stargazers`,
|
||
link: host,
|
||
item: data.map((follower) => ({
|
||
title: `${follower.node.login} starred ${user}/${repo}`,
|
||
author: follower.node.login,
|
||
description: `<a href="https://github.com/${follower.node.login}">${follower.node.login}</a> <br> <img sytle="width:50px;" src='${follower.node.avatarUrl}'>`,
|
||
link: `https://github.com/${follower.node.login}`,
|
||
})),
|
||
};
|
||
};
|