Skip to content

Commit 9ba0998

Browse files
committedDec 16, 2024
Fix up doc build scripts
1 parent 3ea698d commit 9ba0998

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed
 

‎packages/docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"scripts": {
1717
"prebuild": "npx -y tsx@4.7.1 ./scripts/generate-plugin-docs.ts",
1818
"build": "astro check && astro build",
19-
"postbuild": "biome format --write --no-errors-on-unmatched src/content/docs/reference/plugins.md src/content/docs/reference/plugins/*.md",
19+
"postbuild": "[ \"$CF_PAGES\" = \"1\" ] && find dist -mindepth 2 -type f -name 'index.html' -exec bash -c 'f=\"$1\"; d=$(dirname \"$f\"); bn=$(basename \"$d\"); mv -v \"$f\" \"$d/../$bn.html\"' _ {} \\; && find dist -mindepth 1 -type d -empty -print -delete || true",
2020
"dev": "astro dev",
2121
"preremark": ". remark/preremark.sh",
2222
"remark": "remark README.md 'src/content/docs/**/*.{md,mdx}' --verbose -o",

‎packages/docs/src/components/Contributors.astro

+22-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,33 @@ interface Contributor {
1515
const url = new URL('/repos/webpro-nl/knip/contributors', 'https://api.github.com');
1616
url.searchParams.set('per_page', '100');
1717
18-
const contributors: Contributor[] = isFetch
19-
? await fetch(url.href, {
18+
const getAllContributors = async (url: URL) => {
19+
const allContributors: Contributor[] = [];
20+
let nextUrl: string = url.href;
21+
22+
console.log('\n');
23+
while (nextUrl) {
24+
console.log(`Fetching contributors from ${nextUrl}`);
25+
const response = await fetch(nextUrl, {
2026
headers: {
2127
Accept: 'application/vnd.github+json',
2228
Authorization: `Bearer ${GITHUB_TOKEN}`,
2329
'X-GitHub-Api-Version': '2022-11-28',
2430
},
25-
}).then(res => res.json())
31+
});
32+
33+
const contributors = await response.json();
34+
allContributors.push(...contributors);
35+
36+
const linkHeader = response.headers.get('Link');
37+
nextUrl = linkHeader?.match(/<([^>]+)>;\s*rel="next"/)?.[1] || '';
38+
}
39+
40+
return allContributors;
41+
};
42+
43+
const contributors: Contributor[] = isFetch
44+
? await getAllContributors(url)
2645
: JSON.parse(await readFile('mock/contributors.json', 'utf-8'));
2746
2847
if (!Array.isArray(contributors)) console.log(contributors);

0 commit comments

Comments
 (0)
Please sign in to comment.