generated from mintlify/starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
121 lines (117 loc) · 3.38 KB
/
init.js
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const fs = require('fs');
const path = require('path');
const documentationStructure = [
{ name: 'home', type: 'file' },
{
name: 'about-saiku',
type: 'folder',
children: [
{ name: 'overview', type: 'file' },
{ name: 'why-saiku', type: 'file' },
{ name: 'peas-framework', type: 'file' }
]
},
{
name: 'getting-started',
type: 'folder',
children: [
{ name: 'installation', type: 'file' },
{ name: 'configuration', type: 'file' },
{ name: 'quickstart-guide', type: 'file' },
{ name: 'environment-variables', type: 'file' }
]
},
{
name: 'user-guide',
type: 'folder',
children: [
{ name: 'usage-instructions', type: 'file' },
{ name: 'use-cases', type: 'file' }
]
},
{
name: 'api-reference',
type: 'folder',
children: [
{ name: 'introduction', type: 'file' }
]
},
{
name: 'developer-guide',
type: 'folder',
children: [
{ name: 'development-setup', type: 'file' },
{ name: 'contribution-guidelines', type: 'file' },
{ name: 'building-and-testing', type: 'file' },
{ name: 'codebase-architecture', type: 'file' }
]
},
{
name: 'integration-guides',
type: 'folder',
children: [
{ name: 'google-services', type: 'file' },
{ name: 'external-apis', type: 'file' }
]
},
{
name: 'advanced-topics',
type: 'folder',
children: [
{ name: 'modular-design', type: 'file' },
{ name: 'customization', type: 'file' },
{ name: 'future-roadmap', type: 'file' }
]
},
{
name: 'faqs-and-troubleshooting',
type: 'folder',
children: [
{ name: 'faqs', type: 'file' },
{ name: 'troubleshooting', type: 'file' }
]
},
{
name: 'community-and-support',
type: 'folder',
children: [
{ name: 'contributing', type: 'file' },
{ name: 'forums-and-channels', type: 'file' },
{ name: 'feedback-and-issues', type: 'file' }
]
},
{
name: 'api-rate-limits-and-costs',
type: 'folder',
children: [
{ name: 'api-usage', type: 'file' }
]
},
{
name: 'license-and-legal',
type: 'folder',
children: [
{ name: 'licensing', type: 'file' }
]
}
];
function toTitleCase(str) {
return str.replace(/\w\S*/g, txt => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
}
function createDocumentation(structure, basePath = '.') {
structure.forEach(item => {
const itemPath = path.join(basePath, item.name);
if (item.type === 'file') {
const content = `---\ntitle: '${toTitleCase(item.name.replace(/-/g, ' '))}'\ndescription: ''\n---\n`;
fs.writeFileSync(`${itemPath}.mdx`, content);
} else if (item.type === 'folder') {
if (!fs.existsSync(itemPath)) {
fs.mkdirSync(itemPath);
}
if (item.children) {
createDocumentation(item.children, itemPath);
}
}
});
}
createDocumentation(documentationStructure);