@@ -276,6 +276,20 @@ function generateDocComponentsCode(docs) {
276276 return `const docComponents: Record<string, Record<string, React.ComponentType>> = {\n${ componentLines . join ( '\n' ) } \n};` ;
277277}
278278
279+ // Generate component import for manifesto (single index.mdx per locale)
280+ function generateManifestoComponentsCode ( ) {
281+ const componentLines = [ ] ;
282+
283+ for ( const locale of SUPPORTED_LOCALES ) {
284+ const manifestoIndex = path . join ( rootDir , `content/manifesto/${ locale } /index.mdx` ) ;
285+ if ( fs . existsSync ( manifestoIndex ) ) {
286+ componentLines . push ( ` '${ locale } ': require('@content/manifesto/${ locale } /index.mdx').default,` ) ;
287+ }
288+ }
289+
290+ return ` const components: Record<string, React.ComponentType> = {\n${ componentLines . join ( '\n' ) } \n };` ;
291+ }
292+
279293// Main execution
280294function main ( ) {
281295 console . log ( 'Generating MDX metadata...' ) ;
@@ -295,8 +309,9 @@ function main() {
295309 fs . mkdirSync ( outputDir , { recursive : true } ) ;
296310 }
297311
298- const content = `// This file is auto-generated by scripts/generate-metadata.mjs
299- // DO NOT EDIT MANUALLY
312+ const header = `// This file is auto-generated by scripts/generate-metadata.mjs\n// DO NOT EDIT MANUALLY` ;
313+
314+ const content = `${ header }
300315
301316import type { ArticleMetadata } from './articles';
302317import type { DocSection } from './docs';
@@ -319,8 +334,7 @@ export const stackCounts: Record<string, number> = ${JSON.stringify(stackCounts,
319334 // Generate articles.ts file in generated directory
320335 const articlesGeneratedFile = path . join ( outputDir , 'articles.ts' ) ;
321336 const articlesComponentsCode = generateArticleComponentsCode ( articles ) ;
322- const articlesGeneratedContent = `// This file is auto-generated by scripts/generate-metadata.mjs
323- // DO NOT EDIT MANUALLY
337+ const articlesGeneratedContent = `${ header }
324338
325339import { articlesMetadata } from './metadata';
326340
@@ -359,8 +373,7 @@ export function getArticleComponents(locale: string = 'en'): Record<string, Reac
359373 // Generate docs.ts file in generated directory
360374 const docsGeneratedFile = path . join ( outputDir , 'docs.ts' ) ;
361375 const docsComponentsCode = generateDocComponentsCode ( docs ) ;
362- const docsGeneratedContent = `// This file is auto-generated by scripts/generate-metadata.mjs
363- // DO NOT EDIT MANUALLY
376+ const docsGeneratedContent = `${ header }
364377
365378import { docsMetadata } from './metadata';
366379
@@ -395,6 +408,24 @@ export function getDocComponents(locale: string = 'en'): Record<string, React.Co
395408
396409 fs . writeFileSync ( docsGeneratedFile , docsGeneratedContent , 'utf8' ) ;
397410
411+ // Generate manifesto.ts file in generated directory
412+ const manifestoGeneratedFile = path . join ( outputDir , 'manifesto.ts' ) ;
413+ const manifestoComponentsCode = generateManifestoComponentsCode ( ) ;
414+ const manifestoGeneratedContent = `${ header }
415+
416+ /**
417+ * Return the Manifesto MDX React component for a given locale.
418+ * Falls back to the default locale ('en') when the requested locale is missing.
419+ */
420+ export function getManifestoComponent(locale: string = 'en'): React.ComponentType {
421+ ${ manifestoComponentsCode }
422+
423+ return components[locale] || components['en'];
424+ }
425+ ` ;
426+
427+ fs . writeFileSync ( manifestoGeneratedFile , manifestoGeneratedContent , 'utf8' ) ;
428+
398429 // Calculate total docs, articles, and faqs across all locales
399430 const totalDocs = Object . values ( docs ) . reduce ( ( sum , localeDocs ) => sum + localeDocs . length , 0 ) ;
400431 const totalArticles = Object . values ( articles ) . reduce ( ( sum , localeArticles ) => sum + localeArticles . length , 0 ) ;
@@ -408,9 +439,10 @@ export function getDocComponents(locale: string = 'en'): Record<string, React.Co
408439 console . log ( `✅ Generated metadata for ${ totalArticles } articles (${ articlesLocalesCounts } ), ${ totalDocs } docs (${ docsLocalesCounts } ), ${ totalFaqs } faqs (${ faqsLocalesCounts } ), and collections (${ collectionsLocales } )` ) ;
409440 console . log ( `✅ Generated stack counts: ${ stackCountsSummary } ` ) ;
410441 console . log ( `📝 Generated files:` ) ;
411- console . log ( ` - ${ outputFile } ` ) ;
412- console . log ( ` - ${ articlesGeneratedFile } ` ) ;
413- console . log ( ` - ${ docsGeneratedFile } ` ) ;
442+ console . log ( ` - ${ path . relative ( rootDir , outputFile ) } ` ) ;
443+ console . log ( ` - ${ path . relative ( rootDir , articlesGeneratedFile ) } ` ) ;
444+ console . log ( ` - ${ path . relative ( rootDir , docsGeneratedFile ) } ` ) ;
445+ console . log ( ` - ${ path . relative ( rootDir , manifestoGeneratedFile ) } ` ) ;
414446}
415447
416448main ( ) ;
0 commit comments