mirror of
https://github.com/github/awesome-copilot.git
synced 2026-08-25 10:21:40 +00:00
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:
@@ -2,6 +2,7 @@ import { MarkGithubIcon } from "@primer/octicons-react";
|
|||||||
import { Box, Button, ThemeProvider, useTheme } from "@primer/react-brand";
|
import { Box, Button, ThemeProvider, useTheme } from "@primer/react-brand";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
import { contributorsTotal as siteContributorsTotal } from "../../lib/site-data";
|
||||||
import { ContributorsNavButton } from "./ContributorsNavButton";
|
import { ContributorsNavButton } from "./ContributorsNavButton";
|
||||||
import { LanguageSelect } from "./LanguageSelect";
|
import { LanguageSelect } from "./LanguageSelect";
|
||||||
import { LargeFooter } from "./LargeFooter";
|
import { LargeFooter } from "./LargeFooter";
|
||||||
@@ -48,7 +49,7 @@ export function PageShell({
|
|||||||
styles,
|
styles,
|
||||||
currentPage,
|
currentPage,
|
||||||
searchIndex = [],
|
searchIndex = [],
|
||||||
contributorsTotal = 0,
|
contributorsTotal = siteContributorsTotal,
|
||||||
searchAriaLabel = "Search the library",
|
searchAriaLabel = "Search the library",
|
||||||
contributorsCurrent = false,
|
contributorsCurrent = false,
|
||||||
renderFooter = true,
|
renderFooter = true,
|
||||||
@@ -80,7 +81,7 @@ function PageShellBody({
|
|||||||
styles,
|
styles,
|
||||||
currentPage,
|
currentPage,
|
||||||
searchIndex = [],
|
searchIndex = [],
|
||||||
contributorsTotal = 0,
|
contributorsTotal = siteContributorsTotal,
|
||||||
searchAriaLabel = "Search the library",
|
searchAriaLabel = "Search the library",
|
||||||
contributorsCurrent = false,
|
contributorsCurrent = false,
|
||||||
renderFooter = true,
|
renderFooter = true,
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
* by the React components is defined in exactly one place and the shell always
|
* by the React components is defined in exactly one place and the shell always
|
||||||
* gets consistent counts and a consistent search index.
|
* 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 agentsData from "../../public/data/agents.json";
|
||||||
import extensionsData from "../../public/data/extensions.json";
|
import extensionsData from "../../public/data/extensions.json";
|
||||||
import instructionsData from "../../public/data/instructions.json";
|
import instructionsData from "../../public/data/instructions.json";
|
||||||
@@ -20,6 +23,18 @@ import {
|
|||||||
|
|
||||||
const BASE = import.meta.env.BASE_URL ?? "/";
|
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 agents = agentsData.items;
|
||||||
export const extensions = extensionsData.items;
|
export const extensions = extensionsData.items;
|
||||||
export const instructions = instructionsData.items;
|
export const instructions = instructionsData.items;
|
||||||
@@ -36,6 +51,9 @@ export const counts = {
|
|||||||
skills: skills.length,
|
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. */
|
/** Site-wide search index for `TopNavSearch`, shared by every page. */
|
||||||
export const searchIndex: SearchItem[] = buildSearchIndex(
|
export const searchIndex: SearchItem[] = buildSearchIndex(
|
||||||
searchIndexData as GeneratedSearchRecord[],
|
searchIndexData as GeneratedSearchRecord[],
|
||||||
|
|||||||
Reference in New Issue
Block a user