From 23f8fde81396f01bf913cf7f71bcb978d815d926 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Mon, 17 Aug 2026 09:59:37 +1000 Subject: [PATCH] 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 --- website/src/components/brand/PageShell.tsx | 5 +++-- website/src/lib/site-data.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/website/src/components/brand/PageShell.tsx b/website/src/components/brand/PageShell.tsx index aa286487..1c2f908c 100644 --- a/website/src/components/brand/PageShell.tsx +++ b/website/src/components/brand/PageShell.tsx @@ -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, diff --git a/website/src/lib/site-data.ts b/website/src/lib/site-data.ts index 405f61ed..82347b8a 100644 --- a/website/src/lib/site-data.ts +++ b/website/src/lib/site-data.ts @@ -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>; + }; + 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[],