-
Notifications
You must be signed in to change notification settings - Fork 518
Expand file tree
/
Copy pathindex.ts
More file actions
30 lines (26 loc) · 1.16 KB
/
index.ts
File metadata and controls
30 lines (26 loc) · 1.16 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
import { CodeExample } from '../lib/code-examples';
import { apiKeysExamples } from './api-keys';
import { conceptsExamples } from './concepts';
import { customizationExamples } from './customization';
import { paymentsExamples } from './payments';
import { selfHostExamples } from './self-host';
import { setupExamples } from './setup';
import { viteExamples } from './vite-example';
const allExamples: Record<string, Record<string, Record<string, CodeExample[]>>> = {
'setup': setupExamples,
'apps': {...apiKeysExamples, ...paymentsExamples },
'concepts': conceptsExamples,
'getting-started': viteExamples,
'others': selfHostExamples,
'customization': customizationExamples,
};
export function getExample(documentPath: string, exampleName: string): CodeExample[] | undefined {
const [section, ...rest] = documentPath.split('/');
const subsection = rest.join('/');
return allExamples[section]?.[subsection]?.[exampleName];
}
export function getDocumentExamples(documentPath: string): Record<string, CodeExample[]> | undefined {
const [section, ...rest] = documentPath.split('/');
const subsection = rest.join('/');
return allExamples[section]?.[subsection];
}