diff --git a/apps/docs/src/components/Footer/AvatarList.astro b/apps/docs/src/components/Footer/AvatarList.astro index cdfbe59..c8fe863 100644 --- a/apps/docs/src/components/Footer/AvatarList.astro +++ b/apps/docs/src/components/Footer/AvatarList.astro @@ -1,66 +1,66 @@ --- // fetch all commits for just this page's path type Props = { - path: string; + path: string; }; const { path } = Astro.props as Props; -const resolvedPath = `examples/docs/${path}`; +const resolvedPath = `apps/docs/${path}`; const url = `https://api.github.com/repos/ayoayco/astro-reactive-library/commits?path=${resolvedPath}`; const commitsURL = `https://github.com/ayoayco/astro-reactive-library/commits/main/${resolvedPath}`; type Commit = { - author: { - id: string; - login: string; - }; + author: { + id: string; + login: string; + }; }; async function getCommits(url: string) { - try { - const token = import.meta.env.SNOWPACK_PUBLIC_GITHUB_TOKEN ?? 'hello'; - if (!token) { - throw new Error( - 'Cannot find "SNOWPACK_PUBLIC_GITHUB_TOKEN" used for escaping rate-limiting.' - ); - } + try { + const token = import.meta.env.SNOWPACK_PUBLIC_GITHUB_TOKEN ?? "hello"; + if (!token) { + throw new Error( + 'Cannot find "SNOWPACK_PUBLIC_GITHUB_TOKEN" used for escaping rate-limiting.' + ); + } - const auth = `Basic ${Buffer.from(token, 'binary').toString('base64')}`; + const auth = `Basic ${Buffer.from(token, "binary").toString("base64")}`; - const res = await fetch(url, { - method: 'GET', - headers: { - Authorization: auth, - 'User-Agent': 'astro-docs/1.0', - }, - }); + const res = await fetch(url, { + method: "GET", + headers: { + Authorization: auth, + "User-Agent": "astro-docs/1.0", + }, + }); - const data = await res.json(); + const data = await res.json(); - if (!res.ok) { - throw new Error( - `Request to fetch commits failed. Reason: ${res.statusText} + if (!res.ok) { + throw new Error( + `Request to fetch commits failed. Reason: ${res.statusText} Message: ${data.message}` - ); - } + ); + } - return data as Commit[]; - } catch (e) { - console.warn(`[error] /src/components/AvatarList.astro + return data as Commit[]; + } catch (e) { + console.warn(`[error] /src/components/AvatarList.astro ${(e as any)?.message ?? e}`); - return [] as Commit[]; - } + return [] as Commit[]; + } } function removeDups(arr: Commit[]) { - const map = new Map(); + const map = new Map(); - for (let item of arr) { - const author = item.author; - // Deduplicate based on author.id - map.set(author.id, { login: author.login, id: author.id }); - } + for (let item of arr) { + const author = item.author; + // Deduplicate based on author.id + map.set(author.id, { login: author.login, id: author.id }); + } - return [...map.values()]; + return [...map.values()]; } const data = await getCommits(url); @@ -71,97 +71,112 @@ const additionalContributors = unique.length - recentContributors.length; // lis
-
    - {recentContributors.map((item) => ( -
  • - - {`Contributor - -
  • - ))} -
- {additionalContributors > 0 && ( - - {`and ${additionalContributors} additional contributor${ - additionalContributors > 1 ? 's' : '' - }.`} - - )} - {unique.length === 0 && Contributors} +
    + { + recentContributors.map((item) => ( +
  • + + {`Contributor + +
  • + )) + } +
+ { + additionalContributors > 0 && ( + + {`and ${additionalContributors} additional contributor${ + additionalContributors > 1 ? "s" : "" + }.`} + + ) + } + {unique.length === 0 && Contributors}