Skip to content

Commit f1b19cb

Browse files
committed
Some cleanups when collecting contributors
1 parent 1e2b782 commit f1b19cb

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

docs/.vitepress/data/contributors.data.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,23 @@ export default defineLoader({
2929
async load(): Promise<Data> {
3030
let page = 1;
3131
let hasNextPage = true;
32-
const allContributors: Contributor[] = [];
32+
const contributors: Contributor[] = [];
3333

3434
while (hasNextPage) {
3535
const uri = `https://api.github.com/repos/sublimetext-io/docs.sublimetext.io/contributors?per_page=100&page=${page}`;
3636

3737
const response = await fetch(uri);
3838

3939
if (!response.ok) {
40-
return {
41-
contributors: [] as Contributor[]
42-
};
40+
break;
4341
}
4442

4543
const res: GithubContributor[] = await response.json();
4644

4745
if (res.length === 0) {
4846
hasNextPage = false;
4947
} else {
50-
const contributors: Contributor[] = res.map((contributor: GithubContributor) => ({
48+
const contributorsPage: Contributor[] = res.map(contributor => ({
5149
avatar: contributor.avatar_url,
5250
name: contributor.login,
5351
title: 'Contributor',
@@ -56,12 +54,13 @@ export default defineLoader({
5654
]
5755
}));
5856

59-
allContributors.push(...contributors);
57+
contributors.push(...contributorsPage);
6058
page++;
6159
}
6260
}
61+
6362
return {
64-
contributors: allContributors
63+
contributors,
6564
};
6665
}
6766
})

0 commit comments

Comments
 (0)