Skip to content

Commit f9640e3

Browse files
committed
add thank you page
1 parent 60d0e5e commit f9640e3

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed

docs/.vitepress/config/en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ function nav() {
7575
},
7676
],
7777
},
78+
{
79+
text: "Thank You",
80+
link: "/thankyou",
81+
activeMatch: "/thankyou/",
82+
},
7883
{
7984
text: "Legal",
8085
link: "/legal/privacy",

docs/data/contributors.data.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
declare let list: any;
2+
3+
async function getContributors(repoName, page = 1) {
4+
let request = await fetch(`https://api.github.com/repos/${repoName}/contributors?per_page=100&page=${page}`, {
5+
method: 'GET',
6+
headers: {
7+
'Content-Type': 'application/json',
8+
}
9+
});
10+
11+
let contributorsList = await request.json();
12+
return contributorsList;
13+
};
14+
15+
async function getAlllContributors(repoName) {
16+
let contributors = [];
17+
let page = 1;
18+
19+
do {
20+
list = await getContributors(repoName, page);
21+
contributors = contributors.concat(list);
22+
page++;
23+
} while ((await list).length > 0);
24+
return contributors;
25+
}
26+
27+
async function getAllContributorsRecursive(repoName, page = 1, allContributors = []) {
28+
const list = await getContributors(repoName, page);
29+
allContributors = allContributors.concat(list);
30+
31+
if (list.length === 100) {
32+
return getAllContributorsRecursive(repoName, page + 1, allContributors);
33+
}
34+
return allContributors;
35+
}
36+
37+
export default {
38+
async load() {
39+
return await getAllContributorsRecursive("MMRLApp/MMRL");
40+
},
41+
};

docs/en/thankyou.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Thank You
3+
layout: page
4+
---
5+
6+
<script setup>
7+
import { VPTeamPage, VPTeamPageTitle, VPTeamMembers, VPTeamPageSection } from "vitepress/theme";
8+
9+
import { data } from "../data/contributors.data.ts";
10+
import sponsors from "../public/api/sponsors.json";
11+
12+
function toDollars(amount, divideBy = 100.0) {
13+
return `$${(amount / divideBy).toFixed(2)}`;
14+
}
15+
16+
const github = {
17+
svg: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-brand-github"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" /></svg>`
18+
}
19+
20+
const commit = {
21+
svg: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-git-commit"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 12m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" /><path d="M12 3l0 6" /><path d="M12 15l0 6" /></svg>`
22+
}
23+
24+
const _sponsors = sponsors
25+
.map((spon) => {
26+
return {
27+
avatar: spon.avatarUrl,
28+
name: spon.login,
29+
title: `${toDollars(spon.amount)} in total`,
30+
links: [
31+
{
32+
icon: github,
33+
link: spon.url,
34+
},
35+
],
36+
};
37+
})
38+
.sort((a, b) => b.amount - a.amount);
39+
40+
const totalSponsored = sponsors.reduce((acc, current) => acc + current.amount, 0);
41+
42+
const excludedContris = ["DerGoogler", "dependabot[bot]"]
43+
44+
const contributorsExluded = data
45+
.filter((con) => !excludedContris.includes(con.login))
46+
47+
const contributors = contributorsExluded.map((contri) => ({
48+
avatar: contri.avatar_url,
49+
name: contri.login,
50+
title: `${contri.contributions} contribution/s`,
51+
links: [
52+
{
53+
icon: github,
54+
link: contri.html_url,
55+
},
56+
{
57+
icon: commit,
58+
link: `https://github.com/MMRLApp/MMRL/commits?author=${contri.login}`,
59+
},
60+
],
61+
}))
62+
.sort((a, b) => b.contributions - a.contributions);
63+
64+
65+
const totalContributions = contributorsExluded.reduce((acc, current) => acc + current.contributions, 0);
66+
67+
</script>
68+
69+
<VPTeamPage>
70+
<VPTeamPageTitle>
71+
<template #title>Sponsors</template>
72+
<template #lead><u>{{ toDollars(totalSponsored) }}</u> have been total sponsored</template>
73+
</VPTeamPageTitle>
74+
<VPTeamMembers size="medium" :members="_sponsors" />
75+
<VPTeamPageSection>
76+
<template #title>Contributors</template>
77+
<template #lead><u>{{ totalContributions }}</u> total community contributions</template>
78+
<template #members>
79+
<VPTeamMembers size="small" :members="contributors" />
80+
</template>
81+
</VPTeamPageSection>
82+
</VPTeamPage>

0 commit comments

Comments
 (0)