feat: display commit count instead of gitlab stars on the homepage
Merge pull request #4 from bugrakaan/feat-homepage-commit-count
This commit is contained in:
commit
11d4400074
2 changed files with 9 additions and 2 deletions
|
@ -6,6 +6,7 @@ let starCount = 0;
|
|||
let roleMembers = {
|
||||
"1214817156420862012": 50,
|
||||
};
|
||||
let gitCommits = 0;
|
||||
|
||||
async function fetchServerSideData() {
|
||||
console.log("Fetching member count");
|
||||
|
@ -26,18 +27,22 @@ async function fetchServerSideData() {
|
|||
},
|
||||
})
|
||||
: Promise.resolve({ json: () => ({ star_count: 0 }) }), // Default to 0 if no token is provided
|
||||
fetch('https://git.suyu.dev/api/v1/repos/suyu/suyu/commits?stat=false&verification=false&files=false&limit=1')
|
||||
];
|
||||
|
||||
const [res, roles, gitlabRes] = await Promise.all(promises);
|
||||
const [res, roles, gitlabRes, suyuGitRes] = await Promise.all(promises);
|
||||
const jsonPromises = [res.json(), roles.json(), gitlabRes.json()];
|
||||
const [resJson, rolesJson, gitlabResJson] = await Promise.all(jsonPromises);
|
||||
|
||||
|
||||
memberCount = resJson.approximate_member_count;
|
||||
starCount = gitlabResJson.star_count;
|
||||
gitCommits = parseInt(suyuGitRes?.headers?.get('x-total'), 10) || 0;
|
||||
if (DISCORD_USER_TOKEN) roleMembers = rolesJson;
|
||||
|
||||
console.log("Member count:", memberCount);
|
||||
console.log("Stars count:", starCount);
|
||||
console.log('Git commit count', gitCommits);
|
||||
}
|
||||
|
||||
if (!building) {
|
||||
|
@ -52,5 +57,6 @@ export async function load({ cookies }) {
|
|||
memberCount,
|
||||
starCount,
|
||||
roleMembers,
|
||||
gitCommits
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
$: memberCount = parseFloat(data.memberCount?.toPrecision(2));
|
||||
$: contributors = parseFloat(data.roleMembers?.["1214817156420862012"]?.toPrecision(2));
|
||||
$: starCount = parseFloat(data.starCount?.toPrecision(2));
|
||||
$: gitCommits = parseFloat(data.gitCommits?.toPrecision(2));
|
||||
let metadata = {
|
||||
url: "https://suyu.dev",
|
||||
title: "suyu - Open-source, non-profit Switch emulator",
|
||||
|
@ -112,7 +113,7 @@
|
|||
>
|
||||
<h1 class="text-[48px] leading-[0.9]">By the numbers</h1>
|
||||
<HomepageCounter count={contributors} subText="dedicated contributors" />
|
||||
<HomepageCounter count={starCount} subText="GitLab stars" />
|
||||
<HomepageCounter count={gitCommits} subText="Git commits" />
|
||||
<HomepageCounter count={4000} subText="supported games" />
|
||||
<HomepageCounter count={memberCount} subText="members on Discord" />
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue