@@ -23,6 +23,16 @@ const LINK_ROOT = '/docs/storefront/graphql';
2323
2424// ── Step 1: Clean & generate ────────────────────────────────────────────────
2525
26+ // Preserve hand-written files (index.mdx, meta.json) during regeneration
27+ const preserveFiles = [ 'index.mdx' , 'meta.json' ] ;
28+ const preserved = { } ;
29+ for ( const file of preserveFiles ) {
30+ const p = join ( GRAPHQL_DIR , file ) ;
31+ if ( existsSync ( p ) ) {
32+ preserved [ file ] = readFileSync ( p , 'utf8' ) ;
33+ }
34+ }
35+
2636if ( existsSync ( GRAPHQL_DIR ) ) {
2737 rmSync ( GRAPHQL_DIR , { recursive : true } ) ;
2838}
@@ -51,25 +61,14 @@ for (const dir of ['operations', 'types']) {
5161 if ( existsSync ( p ) ) rmSync ( p , { recursive : true } ) ;
5262}
5363
54- // Remove the generated landing page
64+ // Remove the generated landing page (we maintain a custom index.mdx)
5565const generatedPath = join ( GRAPHQL_DIR , 'generated.md' ) ;
5666if ( existsSync ( generatedPath ) ) rmSync ( generatedPath ) ;
5767
58- // Write clean index
59- const indexPath = join ( GRAPHQL_DIR , 'index.md' ) ;
60- writeFileSync ( indexPath , `---
61- title: GraphQL Reference
62- ---
63-
64- The Storefront GraphQL API reference documentation, automatically generated from the schema.
65-
66- Browse all available [Queries](/docs/storefront/graphql/queries) and [Mutations](/docs/storefront/graphql/mutations).
67- ` ) ;
68-
69- writeFileSync ( join ( GRAPHQL_DIR , 'meta.json' ) , JSON . stringify ( {
70- title : 'GraphQL Reference' ,
71- pages : [ 'queries' , 'mutations' ] ,
72- } , null , 2 ) + '\n' ) ;
68+ // Restore hand-written files that were preserved before the clean
69+ for ( const [ file , content ] of Object . entries ( preserved ) ) {
70+ writeFileSync ( join ( GRAPHQL_DIR , file ) , content ) ;
71+ }
7372
7473// ── Step 3: Introspect schema ───────────────────────────────────────────────
7574
0 commit comments