@@ -254,11 +254,13 @@ function generateArticleComponentsCode(articles) {
254254 . join ( '\n' )
255255
256256 if ( componentEntries ) {
257- componentLines . push ( ` '${ locale } ': {\n${ componentEntries } \n },` )
257+ // Quote locale keys that contain hyphens or special characters
258+ const localeKey = locale . includes ( '-' ) ? `'${ locale } '` : locale
259+ componentLines . push ( ` ${ localeKey } : {\n${ componentEntries } \n },` )
258260 }
259261 }
260262
261- return `const articleComponents: Record<string, Record<string, () => Promise<{ default: React.ComponentType }>>> = {\n${ componentLines . join ( '\n' ) } \n}; `
263+ return `const articleComponents: Record<string, Record<string, () => Promise<{ default: React.ComponentType }>>> = {\n${ componentLines . join ( '\n' ) } \n}`
262264}
263265
264266// Generate component imports for docs
@@ -273,11 +275,13 @@ function generateDocComponentsCode(docs) {
273275 . join ( '\n' )
274276
275277 if ( componentEntries ) {
276- componentLines . push ( ` '${ locale } ': {\n${ componentEntries } \n },` )
278+ // Quote locale keys that contain hyphens or special characters
279+ const localeKey = locale . includes ( '-' ) ? `'${ locale } '` : locale
280+ componentLines . push ( ` ${ localeKey } : {\n${ componentEntries } \n },` )
277281 }
278282 }
279283
280- return `const docComponents: Record<string, Record<string, () => Promise<{ default: React.ComponentType }>>> = {\n${ componentLines . join ( '\n' ) } \n}; `
284+ return `const docComponents: Record<string, Record<string, () => Promise<{ default: React.ComponentType }>>> = {\n${ componentLines . join ( '\n' ) } \n}`
281285}
282286
283287// Generate component import for manifesto (single index.mdx per locale)
@@ -287,13 +291,15 @@ function generateManifestoComponentsCode() {
287291 for ( const locale of SUPPORTED_LOCALES ) {
288292 const manifestoIndex = path . join ( rootDir , `content/manifesto/${ locale } /index.mdx` )
289293 if ( fs . existsSync ( manifestoIndex ) ) {
294+ // Quote locale keys that contain hyphens or special characters
295+ const localeKey = locale . includes ( '-' ) ? `'${ locale } '` : locale
290296 componentLines . push (
291- ` ' ${ locale } ' : () => import('@content/manifesto/${ locale } /index.mdx'),`
297+ ` ${ localeKey } : () => import('@content/manifesto/${ locale } /index.mdx'),`
292298 )
293299 }
294300 }
295301
296- return ` const components: Record<string, () => Promise<{ default: React.ComponentType }>> = {\n${ componentLines . join ( '\n' ) } \n }; `
302+ return ` const components: Record<string, () => Promise<{ default: React.ComponentType }>> = {\n${ componentLines . join ( '\n' ) } \n }`
297303}
298304
299305// Main execution
@@ -345,36 +351,36 @@ export const stackCounts: Record<string, number> = ${JSON.stringify(stackCounts,
345351import { articlesMetadata } from './metadata';
346352
347353export type ArticleMetadata = {
348- title: string;
349- description: string;
350- date: string;
351- slug: string;
352- };
354+ title: string
355+ description: string
356+ date: string
357+ slug: string
358+ }
353359
354360// Get articles for a specific locale with fallback to English
355361export function getArticles(locale: string = 'en'): ArticleMetadata[] {
356- return articlesMetadata[locale] || articlesMetadata['en'] || [];
362+ return articlesMetadata[locale] || articlesMetadata.en || []
357363}
358364
359365// Get all articles (backward compatibility)
360- export const articles: ArticleMetadata[] = getArticles('en');
366+ export const articles: ArticleMetadata[] = getArticles('en')
361367
362368// Get a specific article by slug for a given locale
363369export function getArticleBySlug(slug: string, locale: string = 'en'): ArticleMetadata | undefined {
364- const localeArticles = getArticles(locale);
365- return localeArticles.find(( article) => article.slug === slug);
370+ const localeArticles = getArticles(locale)
371+ return localeArticles.find(article => article.slug === slug)
366372}
367373
368374// MDX components mapping for all locales (dynamic imports)
369375${ articlesComponentsCode }
370376
371377// Get a specific article component for a given locale and slug
372378export async function getArticleComponent(locale: string = 'en', slug: string): Promise<React.ComponentType | null> {
373- const loaders = articleComponents[locale] || articleComponents['en'];
374- const loader = loaders?.[slug];
375- if (!loader) return null;
376- const mdxModule = await loader();
377- return mdxModule.default;
379+ const loaders = articleComponents[locale] || articleComponents.en
380+ const loader = loaders?.[slug]
381+ if (!loader) return null
382+ const mdxModule = await loader()
383+ return mdxModule.default
378384}
379385`
380386
@@ -388,35 +394,35 @@ export async function getArticleComponent(locale: string = 'en', slug: string):
388394import { docsMetadata } from './metadata';
389395
390396export type DocSection = {
391- id: string;
392- title: string;
393- slug: string;
394- };
397+ id: string
398+ title: string
399+ slug: string
400+ }
395401
396402// Get doc sections for a specific locale with fallback to English
397403export function getDocSections(locale: string): DocSection[] {
398- return docsMetadata[locale] || docsMetadata['en'] || [];
404+ return docsMetadata[locale] || docsMetadata.en || []
399405}
400406
401407// Get all doc sections (backward compatibility)
402- export const docSections: DocSection[] = getDocSections('en');
408+ export const docSections: DocSection[] = getDocSections('en')
403409
404410// Get a specific doc by slug for a given locale
405411export function getDocBySlug(slug: string, locale: string = 'en'): DocSection | undefined {
406- const sections = getDocSections(locale);
407- return sections.find(( doc) => doc.slug === slug);
412+ const sections = getDocSections(locale)
413+ return sections.find(doc => doc.slug === slug)
408414}
409415
410416// MDX components mapping for all locales (dynamic imports)
411417${ docsComponentsCode }
412418
413419// Get a specific doc component for a given locale and slug
414420export async function getDocComponent(locale: string = 'en', slug: string): Promise<React.ComponentType | null> {
415- const loaders = docComponents[locale] || docComponents['en'];
416- const loader = loaders?.[slug];
417- if (!loader) return null;
418- const mdxModule = await loader();
419- return mdxModule.default;
421+ const loaders = docComponents[locale] || docComponents.en
422+ const loader = loaders?.[slug]
423+ if (!loader) return null
424+ const mdxModule = await loader()
425+ return mdxModule.default
420426}
421427`
422428
@@ -434,9 +440,9 @@ export async function getDocComponent(locale: string = 'en', slug: string): Prom
434440export async function getManifestoComponent(locale: string = 'en'): Promise<React.ComponentType> {
435441${ manifestoComponentsCode }
436442
437- const loader = components[locale] || components['en'];
438- const mdxModule = await loader();
439- return mdxModule.default;
443+ const loader = components[locale] || components.en
444+ const mdxModule = await loader()
445+ return mdxModule.default
440446}
441447`
442448
0 commit comments