From 00da88af22e3d24d3273a8514b61e49b5b200636 Mon Sep 17 00:00:00 2001 From: Mike Perrotti Date: Tue, 3 Dec 2024 18:18:14 -0500 Subject: [PATCH] generated/components.json - includes link to component code on GitHub (#5344) --- packages/react/script/components-json/build.ts | 6 +++++- packages/react/script/components-json/component.schema.json | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react/script/components-json/build.ts b/packages/react/script/components-json/build.ts index c698b1a0a0a..33c7a82f7bf 100644 --- a/packages/react/script/components-json/build.ts +++ b/packages/react/script/components-json/build.ts @@ -22,6 +22,7 @@ type Component = { | '@primer/react/experimental' | '@primer/react/drafts' stories: Array<{id: string; code?: string}> + source?: string } const ajv = new Ajv() @@ -114,7 +115,10 @@ const components = docsFiles.map(docsFilepath => { } // TODO: Provide default type and description for sx and ref props - return docs + return { + source: `https://github.com/primer/react/tree/main/packages/react/${docsFilepath.substring(0, docsFilepath.lastIndexOf('/'))}`, + ...docs, + } }) const data = {schemaVersion: 2, components: keyBy(components, 'id')} diff --git a/packages/react/script/components-json/component.schema.json b/packages/react/script/components-json/component.schema.json index 4bc4f0037bc..7fe4969c043 100644 --- a/packages/react/script/components-json/component.schema.json +++ b/packages/react/script/components-json/component.schema.json @@ -77,6 +77,10 @@ "type": "string", "description": "The path to import the component from. i.e. '@primer/react/experimental'" }, + "source": { + "type": "string", + "description": "Link to the component source on GitHub" + }, "stories": { "type": "array",