diff --git a/src/components/contributors.astro b/src/components/contributors.astro index 9fb0a012..6bbecff3 100644 --- a/src/components/contributors.astro +++ b/src/components/contributors.astro @@ -5,10 +5,10 @@ interface Props { } const { repo, file } = Astro.props; -// Build an API URL that gets the 100 most recent commits for the specified file. +// Build an API URL that gets the 100 most recent commits for the overall repo. // See https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits const url = new URL(`https://api.github.com/repos/${repo}/commits`); -url.searchParams.set('per_page', 1000); +url.searchParams.set('per_page', 100); // Fetch commits from the GitHub API const commits = await fetch(url, { @@ -19,7 +19,11 @@ const commits = await fetch(url, { }).then((res) => res.json()); function removeDuplicates(commits) { - if (!commits) return []; + if (!Array.isArray(commits)) { + throw new Error( + `GitHub API did not return a commits array. Check the repo name, authentication, and rate limits.\nAPI response: ${JSON.stringify(commits)}` + ); + } const map = new Map(); for (const commit of commits) { const author = commit.author;