fix(website): source contributor count from .all-contributorsrc

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 80686fef-efe3-4cdd-8cd6-bfa61a5d0af6
This commit is contained in:
Aaron Powell
2026-08-17 09:59:37 +10:00
parent 21db4711f5
commit 23f8fde813
2 changed files with 21 additions and 2 deletions
+3 -2
View File
@@ -2,6 +2,7 @@ import { MarkGithubIcon } from "@primer/octicons-react";
import { Box, Button, ThemeProvider, useTheme } from "@primer/react-brand";
import type { ReactNode } from "react";
import { contributorsTotal as siteContributorsTotal } from "../../lib/site-data";
import { ContributorsNavButton } from "./ContributorsNavButton";
import { LanguageSelect } from "./LanguageSelect";
import { LargeFooter } from "./LargeFooter";
@@ -48,7 +49,7 @@ export function PageShell({
styles,
currentPage,
searchIndex = [],
contributorsTotal = 0,
contributorsTotal = siteContributorsTotal,
searchAriaLabel = "Search the library",
contributorsCurrent = false,
renderFooter = true,
@@ -80,7 +81,7 @@ function PageShellBody({
styles,
currentPage,
searchIndex = [],
contributorsTotal = 0,
contributorsTotal = siteContributorsTotal,
searchAriaLabel = "Search the library",
contributorsCurrent = false,
renderFooter = true,
+18
View File
@@ -5,6 +5,9 @@
* by the React components is defined in exactly one place and the shell always
* gets consistent counts and a consistent search index.
*/
import fs from "node:fs";
import path from "node:path";
import agentsData from "../../public/data/agents.json";
import extensionsData from "../../public/data/extensions.json";
import instructionsData from "../../public/data/instructions.json";
@@ -20,6 +23,18 @@ import {
const BASE = import.meta.env.BASE_URL ?? "/";
function getContributorsTotal(): number {
try {
const rcPath = path.resolve(process.cwd(), "..", ".all-contributorsrc");
const rc = JSON.parse(fs.readFileSync(rcPath, "utf8")) as {
contributors?: Array<Record<string, unknown>>;
};
return Array.isArray(rc.contributors) ? rc.contributors.length : 0;
} catch {
return 0;
}
}
export const agents = agentsData.items;
export const extensions = extensionsData.items;
export const instructions = instructionsData.items;
@@ -36,6 +51,9 @@ export const counts = {
skills: skills.length,
};
/** Repo contributor count, sourced from the root .all-contributorsrc file. */
export const contributorsTotal = getContributorsTotal();
/** Site-wide search index for `TopNavSearch`, shared by every page. */
export const searchIndex: SearchItem[] = buildSearchIndex(
searchIndexData as GeneratedSearchRecord[],