Skip to content

Commit 397e2bd

Browse files
committed
add contributors
1 parent 1e02cfd commit 397e2bd

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

docs/.vitepress/config/shared.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import ViteYaml from "@modyfi/vite-plugin-yaml";
33
import { pagefindPlugin } from "vitepress-plugin-pagefind";
44
// Imports
55
import { defineConfig, SiteConfig } from "vitepress";
6-
import { writeFile, copyFile } from "fs/promises";
6+
import { writeFile, unlink } from "fs/promises";
77
import { resolve } from "path";
88
import { blacklistJSONstringify } from "../../data/blacklist";
99
import { changelogJSONstringify } from "../../data/changelog";
1010
import repositories from "../../../meta/repositories.json";
11-
import { time } from "console";
11+
import sponsors from "../../../meta/sponsors.json";
12+
import { getAllContributorsRecursive } from "../../data/contributors.data";
1213

1314
export const shared = defineConfig({
1415
vite: {
@@ -51,7 +52,10 @@ export const shared = defineConfig({
5152
},
5253
buildEnd: async (config: SiteConfig) => {
5354
const publicApi = resolve(config.outDir, "api");
55+
const placeholder = resolve(publicApi, "placeholder");
5456
const publicRepoList = resolve(publicApi, "repositories.json");
57+
const publicSponList = resolve(publicApi, "sponsors.json");
58+
const publicConList = resolve(publicApi, "contributors.json");
5559
const publicBlackList = resolve(publicApi, "blacklist.json");
5660
const publicChangelogList = resolve(publicApi, "changelog.json");
5761

@@ -70,8 +74,29 @@ export const shared = defineConfig({
7074
};
7175
});
7276

77+
const newContributors = async () => {
78+
const contributors = await getAllContributorsRecursive("MMRLApp/MMRL");
79+
80+
const excludedContributors = ["DerGoogler", "dependabot[bot]"]
81+
82+
const contributorsExluded = contributors
83+
.filter((con) => !excludedContributors.includes(con.login))
84+
85+
return contributorsExluded.map((contributor) => {
86+
return {
87+
avatarUrl: contributor.avatar_url,
88+
login: contributor.login,
89+
url: contributor.html_url,
90+
contributions: contributor.contributions,
91+
};
92+
});
93+
};
94+
7395
await writeFile(publicRepoList, JSON.stringify(await Promise.all(newRepositories), null, 4));
96+
await writeFile(publicSponList, JSON.stringify(await Promise.all(sponsors), null, 4));
97+
await writeFile(publicConList, JSON.stringify(await newContributors(), null, 4));
7498
await writeFile(publicBlackList, blacklistJSONstringify);
7599
await writeFile(publicChangelogList, changelogJSONstringify);
100+
await unlink(placeholder);
76101
},
77102
});

docs/data/contributors.data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
declare let list: any;
22

3-
async function getContributors(repoName, page = 1) {
3+
export async function getContributors(repoName: string, page: number = 1) {
44
let request = await fetch(`https://api.github.com/repos/${repoName}/contributors?per_page=100&page=${page}`, {
55
method: 'GET',
66
headers: {
@@ -12,7 +12,7 @@ async function getContributors(repoName, page = 1) {
1212
return contributorsList;
1313
};
1414

15-
async function getAlllContributors(repoName) {
15+
export async function getAlllContributors(repoName: string) {
1616
let contributors = [];
1717
let page = 1;
1818

@@ -24,7 +24,7 @@ async function getAlllContributors(repoName) {
2424
return contributors;
2525
}
2626

27-
async function getAllContributorsRecursive(repoName, page = 1, allContributors = []) {
27+
export async function getAllContributorsRecursive(repoName: string, page: number = 1, allContributors: any[] = []) {
2828
const list = await getContributors(repoName, page);
2929
allContributors = allContributors.concat(list);
3030

docs/en/thankyou.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layout: page
77
import { VPTeamPage, VPTeamPageTitle, VPTeamMembers, VPTeamPageSection } from "vitepress/theme";
88

99
import { data } from "../data/contributors.data.ts";
10-
import sponsors from "../public/api/sponsors.json";
10+
import sponsors from "../../meta/sponsors.json";
1111

1212
function toDollars(amount, divideBy = 100.0) {
1313
return `$${(amount / divideBy).toFixed(2)}`;

docs/public/api/placeholder

Whitespace-only changes.

docs/public/api/sponsors.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)