-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdocs.ts
More file actions
103 lines (96 loc) · 3.87 KB
/
Copy pathdocs.ts
File metadata and controls
103 lines (96 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// This file is auto-generated by scripts/generate-metadata.ts
// DO NOT EDIT MANUALLY
import { docsMetadata } from './metadata'
export type DocSection = {
id: string
title: string
slug: string
}
// Get doc sections for a specific locale with fallback to English
export function getDocSections(locale: string): DocSection[] {
return docsMetadata[locale] || docsMetadata.en || []
}
// Get all doc sections (backward compatibility)
export const docSections: DocSection[] = getDocSections('en')
// Get a specific doc by slug for a given locale
export function getDocBySlug(slug: string, locale: string = 'en'): DocSection | undefined {
const sections = getDocSections(locale)
return sections.find(doc => doc.slug === slug)
}
// MDX components mapping for all locales (dynamic imports)
const docComponents: Record<
string,
Record<string, () => Promise<{ default: React.ComponentType }>>
> = {
en: {
'data-sources': () => import('@content/docs/en/data-sources.mdx'),
'getting-started': () => import('@content/docs/en/getting-started.mdx'),
welcome: () => import('@content/docs/en/welcome.mdx'),
},
de: {
'data-sources': () => import('@content/docs/de/data-sources.mdx'),
'getting-started': () => import('@content/docs/de/getting-started.mdx'),
welcome: () => import('@content/docs/de/welcome.mdx'),
},
es: {
'data-sources': () => import('@content/docs/es/data-sources.mdx'),
'getting-started': () => import('@content/docs/es/getting-started.mdx'),
welcome: () => import('@content/docs/es/welcome.mdx'),
},
fr: {
'data-sources': () => import('@content/docs/fr/data-sources.mdx'),
'getting-started': () => import('@content/docs/fr/getting-started.mdx'),
welcome: () => import('@content/docs/fr/welcome.mdx'),
},
id: {
'data-sources': () => import('@content/docs/id/data-sources.mdx'),
'getting-started': () => import('@content/docs/id/getting-started.mdx'),
welcome: () => import('@content/docs/id/welcome.mdx'),
},
ja: {
'data-sources': () => import('@content/docs/ja/data-sources.mdx'),
'getting-started': () => import('@content/docs/ja/getting-started.mdx'),
welcome: () => import('@content/docs/ja/welcome.mdx'),
},
ko: {
'data-sources': () => import('@content/docs/ko/data-sources.mdx'),
'getting-started': () => import('@content/docs/ko/getting-started.mdx'),
welcome: () => import('@content/docs/ko/welcome.mdx'),
},
pt: {
'data-sources': () => import('@content/docs/pt/data-sources.mdx'),
'getting-started': () => import('@content/docs/pt/getting-started.mdx'),
welcome: () => import('@content/docs/pt/welcome.mdx'),
},
ru: {
'data-sources': () => import('@content/docs/ru/data-sources.mdx'),
'getting-started': () => import('@content/docs/ru/getting-started.mdx'),
welcome: () => import('@content/docs/ru/welcome.mdx'),
},
tr: {
'data-sources': () => import('@content/docs/tr/data-sources.mdx'),
'getting-started': () => import('@content/docs/tr/getting-started.mdx'),
welcome: () => import('@content/docs/tr/welcome.mdx'),
},
'zh-Hans': {
'data-sources': () => import('@content/docs/zh-Hans/data-sources.mdx'),
'getting-started': () => import('@content/docs/zh-Hans/getting-started.mdx'),
welcome: () => import('@content/docs/zh-Hans/welcome.mdx'),
},
'zh-Hant': {
'data-sources': () => import('@content/docs/zh-Hant/data-sources.mdx'),
'getting-started': () => import('@content/docs/zh-Hant/getting-started.mdx'),
welcome: () => import('@content/docs/zh-Hant/welcome.mdx'),
},
}
// Get a specific doc component for a given locale and slug
export async function getDocComponent(
locale: string = 'en',
slug: string
): Promise<React.ComponentType | null> {
const loaders = docComponents[locale] || docComponents.en
const loader = loaders?.[slug]
if (!loader) return null
const mdxModule = await loader()
return mdxModule.default
}