create-boltdocs 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +41 -496
- package/dist/index.mjs +41 -496
- package/dist/templates/base/boltdocs.config.ts +35 -0
- package/dist/templates/base/docs/getting-started/index.md +33 -0
- package/dist/templates/base/docs/layout.tsx +78 -0
- package/dist/templates/base/docs/pages-external/index.tsx +23 -0
- package/dist/templates/base/index.css +12 -0
- package/dist/templates/base/index.html +11 -0
- package/dist/templates/base/package.json +25 -0
- package/dist/templates/base/public/dark.svg +4 -0
- package/dist/templates/base/public/light.svg +4 -0
- package/dist/templates/base/src/components/footer.tsx +7 -0
- package/dist/templates/base/src/pages/home.tsx +43 -0
- package/dist/templates/base/tsconfig.json +22 -0
- package/dist/templates/base/tsconfig.node.json +10 -0
- package/dist/templates/i18n/boltdocs.config.ts +39 -0
- package/dist/templates/i18n/docs/es/getting-started/index.md +33 -0
- package/dist/templates/i18n/docs/getting-started/index.md +33 -0
- package/dist/templates/i18n/docs/layout.tsx +80 -0
- package/dist/templates/i18n/docs/pages-external/index.tsx +23 -0
- package/dist/templates/i18n/index.css +12 -0
- package/dist/templates/i18n/index.html +11 -0
- package/dist/templates/i18n/package.json +25 -0
- package/dist/templates/i18n/public/dark.svg +4 -0
- package/dist/templates/i18n/public/light.svg +4 -0
- package/dist/templates/i18n/src/components/footer.tsx +15 -0
- package/dist/templates/i18n/src/pages/home.tsx +43 -0
- package/dist/templates/i18n/tsconfig.json +22 -0
- package/dist/templates/i18n/tsconfig.node.json +10 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -25,462 +25,12 @@ let node_fs = require("node:fs");
|
|
|
25
25
|
node_fs = __toESM(node_fs);
|
|
26
26
|
let node_path = require("node:path");
|
|
27
27
|
node_path = __toESM(node_path);
|
|
28
|
+
let node_url = require("node:url");
|
|
28
29
|
let node_child_process = require("node:child_process");
|
|
29
30
|
let prompts = require("prompts");
|
|
30
31
|
prompts = __toESM(prompts);
|
|
31
32
|
let picocolors = require("picocolors");
|
|
32
33
|
picocolors = __toESM(picocolors);
|
|
33
|
-
//#region src/templates/shared.ts
|
|
34
|
-
function getPackageJson(projectName) {
|
|
35
|
-
return {
|
|
36
|
-
name: projectName,
|
|
37
|
-
version: "1.0.0",
|
|
38
|
-
private: true,
|
|
39
|
-
type: "module",
|
|
40
|
-
scripts: {
|
|
41
|
-
dev: "boltdocs",
|
|
42
|
-
build: "boltdocs build",
|
|
43
|
-
preview: "boltdocs preview",
|
|
44
|
-
doctor: "boltdocs doctor",
|
|
45
|
-
"lint:md": "markdownlint-cli2 \"docs/**/*.{md,mdx}\"",
|
|
46
|
-
"lint:md:fix": "markdownlint-cli2 --fix \"docs/**/*.{md,mdx}\""
|
|
47
|
-
},
|
|
48
|
-
dependencies: {
|
|
49
|
-
react: "19.2.5",
|
|
50
|
-
"react-dom": "19.2.5",
|
|
51
|
-
boltdocs: "latest"
|
|
52
|
-
},
|
|
53
|
-
devDependencies: {
|
|
54
|
-
typescript: "^5.7.0",
|
|
55
|
-
"@types/react": "^19.2.14",
|
|
56
|
-
"@types/react-dom": "^19.2.3",
|
|
57
|
-
"markdownlint-cli2": "^0.22.0",
|
|
58
|
-
vite: "^7.0.0",
|
|
59
|
-
tailwindcss: "^4.0.0",
|
|
60
|
-
"@tailwindcss/vite": "^4.2.2"
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const gitignoreContent = `node_modules
|
|
65
|
-
dist
|
|
66
|
-
.DS_Store
|
|
67
|
-
.boltdocs
|
|
68
|
-
`;
|
|
69
|
-
const markdownlintContent = `# Default state for all rules
|
|
70
|
-
default: true
|
|
71
|
-
|
|
72
|
-
# MD013/line-length - Line length
|
|
73
|
-
MD013: false # Too restrictive for technical docs with long URLs and strings
|
|
74
|
-
|
|
75
|
-
# MD024/no-duplicate-heading/no-duplicate-header
|
|
76
|
-
MD024:
|
|
77
|
-
siblings_only: true
|
|
78
|
-
|
|
79
|
-
# MD033/no-inline-html - Inline HTML
|
|
80
|
-
MD033: false # Disabled because we use MDX which uses JSX and HTML extensively
|
|
81
|
-
|
|
82
|
-
# MD041/first-line-heading/first-line-h1 - First line in a file should be a top-level heading
|
|
83
|
-
MD041: false # Disabled since we use frontmatter for title/metadata
|
|
84
|
-
|
|
85
|
-
# MD025/single-title/single-h1
|
|
86
|
-
MD025: false
|
|
87
|
-
|
|
88
|
-
# MD051/link-fragments
|
|
89
|
-
MD051: false # Sometimes fragments aren't fully resolved locally by the linter
|
|
90
|
-
`;
|
|
91
|
-
const markdownlintignoreContent = `.git
|
|
92
|
-
**/node_modules
|
|
93
|
-
node_modules
|
|
94
|
-
dist
|
|
95
|
-
`;
|
|
96
|
-
function getLogoLight() {
|
|
97
|
-
return `<svg width="60" height="51" viewBox="0 0 60 51" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
98
|
-
<path d="M29.4449 0H19.4449V16.5L29.4449 6.5V0Z" fill="white"/>
|
|
99
|
-
<path d="M26.9449 22.7265C26.9449 22.5077 21.2201 27.0658 16.9449 28.5C13.7491 29.5721 12.3156 29.5038 8.94486 29.5C5.59532 29.4963 0 28.5 0 28.5C0 28.5 5.57953 28.5146 8.94486 27.5C12.5409 26.4158 14.8203 25.5843 17.9449 23.5C23.3445 19.898 29.4449 11.5 29.4449 11.5L29.9449 18C29.9449 18 33.5825 15.8308 36.4449 15C39.4452 14.1291 44.4449 14 44.4449 14C44.4449 14 36.9449 19 34.4449 21.5C31.5322 24.4126 29.8582 26.9017 29.4449 31C29.1217 34.2041 29.4771 36.4508 31.4449 39C33.5792 41.765 35.952 43.0183 39.4449 43C42.677 42.9831 45.3003 42.4182 47.4449 40C49.7406 37.4113 50.2495 34.4466 49.9449 31C49.6603 27.7804 48.4876 25.4953 45.9449 23.5C43.2931 21.4191 36.4449 24 36.4449 24L47.9449 15C47.9449 15 51.5761 16.771 53.4449 18.5C55.711 20.5967 56.7467 22.1546 57.9449 25C59.1784 27.9295 59.4832 29.8216 59.4449 33C59.4089 35.9867 59.179 37.78 57.9449 40.5C56.8475 42.9185 55.8511 44.6507 53.9449 46.5C51.9236 48.4609 50.5803 49.0076 47.9449 50C45.5414 50.9051 44.0131 51 41.4449 51C38.8766 51 37.3235 50.9685 34.9449 50C32.4851 48.9985 29.4449 46 29.4449 46V51H19.4449V37.9904L22.9449 31.4226L26.9449 22.7265Z" fill="white"/>
|
|
100
|
-
</svg>`;
|
|
101
|
-
}
|
|
102
|
-
function getLogoDark() {
|
|
103
|
-
return `<svg width="60" height="52" viewBox="0 0 60 52" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
104
|
-
<path d="M29.4449 0H19.4449V16.5L29.4449 6.5V0Z" fill="black"/>
|
|
105
|
-
<path d="M26.9449 22.7265C26.9449 22.5077 21.2201 27.0658 16.9449 28.5C13.7491 29.5721 12.3156 29.5038 8.94486 29.5C5.59532 29.4963 0 28.5 0 28.5C0 28.5 5.57953 28.5146 8.94486 27.5C12.5409 26.4158 14.8203 25.5843 17.9449 23.5C23.3445 19.898 29.4449 11.5 29.4449 11.5L29.9449 18.5C29.9449 18.5 33.5124 15.5332 36.4449 15C41.9449 14 45.4449 15 45.4449 15C45.4449 15 36.9449 19 34.4449 21.5C31.5322 24.4126 29.8582 26.9017 29.4449 31C29.1217 34.2041 29.4771 36.4508 31.4449 39C33.5792 41.765 35.952 43.0183 39.4449 43C42.677 42.9831 45.3003 42.4182 47.4449 40C49.7406 37.4113 50.2495 34.4466 49.9449 31C49.6603 27.7804 48.4876 25.4953 45.9449 23.5C43.2931 21.4191 36.4449 24 36.4449 24L47.4449 15.5C47.4449 15.5 50.4449 16 53.4449 19C56.4449 22 57.4449 23.5 57.9449 24.5C58.4449 25.5 59.9449 28.5 59.9449 33.5C59.9449 36.4869 59.9449 37.5 57.9449 41.5C55.9449 45.5 52.9449 47.5 52.9449 47.5C52.9449 47.5 51.9449 48.5 49.9449 49.5C47.9449 50.5 45.9289 50.8863 44.9449 51.1121C43.2783 51.4944 42.7023 51.5 41.4449 51.5C40.6256 51.5 39.3731 51.3693 37.9449 51.0624C36.9972 50.8587 35.9722 50.5774 34.9449 50.2051C33.7409 49.7688 32.5339 49.2076 31.4449 48.5C30.6262 47.9681 29.4449 47 29.4449 47V51H19.4449V37.9904L22.9449 31.4226L26.9449 22.7265Z" fill="black"/>
|
|
106
|
-
</svg>`;
|
|
107
|
-
}
|
|
108
|
-
function getBoltdocsConfig(projectName, options = {}) {
|
|
109
|
-
const i18nConfig = options.i18n ? `
|
|
110
|
-
i18n: {
|
|
111
|
-
defaultLocale: 'en',
|
|
112
|
-
locales: {
|
|
113
|
-
en: 'English',
|
|
114
|
-
es: 'Español'
|
|
115
|
-
},
|
|
116
|
-
localeConfigs: {
|
|
117
|
-
en: { label: 'English', direction: 'ltr' },
|
|
118
|
-
es: { label: 'Español', direction: 'ltr' }
|
|
119
|
-
}
|
|
120
|
-
},` : "";
|
|
121
|
-
return `import { defineConfig } from 'boltdocs';
|
|
122
|
-
|
|
123
|
-
export default defineConfig({${options.homePage ? `
|
|
124
|
-
homePage: '${options.homePage}',` : ""}${i18nConfig}
|
|
125
|
-
theme: {
|
|
126
|
-
title: '${projectName}',
|
|
127
|
-
logo: {
|
|
128
|
-
light: '/logo-dark.svg',
|
|
129
|
-
dark: '/logo-light.svg',
|
|
130
|
-
alt: '${projectName} Logo'
|
|
131
|
-
},
|
|
132
|
-
navbar: [
|
|
133
|
-
{ label: 'Home', href: '/' },
|
|
134
|
-
{ label: 'Documentation', href: '/docs' },
|
|
135
|
-
],
|
|
136
|
-
socialLinks: [
|
|
137
|
-
{ icon: 'github', link: 'https://github.com/jesusalcaladev/boltdocs' }
|
|
138
|
-
]
|
|
139
|
-
}
|
|
140
|
-
});`;
|
|
141
|
-
}
|
|
142
|
-
function getIndexCss() {
|
|
143
|
-
return `
|
|
144
|
-
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');
|
|
145
|
-
|
|
146
|
-
@import "tailwindcss";
|
|
147
|
-
@import "boltdocs/theme/neutral.css";
|
|
148
|
-
|
|
149
|
-
/*
|
|
150
|
-
@source directive tells Tailwind to scan Boltdocs client components
|
|
151
|
-
inside node_modules for class usage and generate the necessary CSS.
|
|
152
|
-
*/
|
|
153
|
-
@source "./node_modules/boltdocs/src/client";
|
|
154
|
-
`;
|
|
155
|
-
}
|
|
156
|
-
function getLayoutPage() {
|
|
157
|
-
return `import {
|
|
158
|
-
DocsLayout,
|
|
159
|
-
Navbar,
|
|
160
|
-
Sidebar,
|
|
161
|
-
OnThisPage,
|
|
162
|
-
Head,
|
|
163
|
-
Breadcrumbs,
|
|
164
|
-
PageNav,
|
|
165
|
-
ErrorBoundary,
|
|
166
|
-
CopyMarkdown,
|
|
167
|
-
useRoutes,
|
|
168
|
-
useConfig,
|
|
169
|
-
useLocation
|
|
170
|
-
} from 'boltdocs/client'
|
|
171
|
-
|
|
172
|
-
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
173
|
-
const { routes: filteredRoutes, allRoutes, currentRoute } = useRoutes()
|
|
174
|
-
const { pathname } = useLocation()
|
|
175
|
-
const config = useConfig()
|
|
176
|
-
|
|
177
|
-
const isDocs = pathname.startsWith('/docs')
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<DocsLayout>
|
|
181
|
-
<Head
|
|
182
|
-
siteTitle={config.theme?.title}
|
|
183
|
-
siteDescription={config.theme?.description}
|
|
184
|
-
routes={allRoutes}
|
|
185
|
-
/>
|
|
186
|
-
<Navbar />
|
|
187
|
-
|
|
188
|
-
<DocsLayout.Body>
|
|
189
|
-
{isDocs && <Sidebar routes={filteredRoutes} config={config} />}
|
|
190
|
-
|
|
191
|
-
<DocsLayout.Content>
|
|
192
|
-
<DocsLayout.ContentMdx>
|
|
193
|
-
{isDocs && (
|
|
194
|
-
<DocsLayout.ContentHeader>
|
|
195
|
-
<Breadcrumbs />
|
|
196
|
-
<CopyMarkdown
|
|
197
|
-
mdxRaw={currentRoute?._rawContent}
|
|
198
|
-
route={currentRoute}
|
|
199
|
-
config={config.theme?.copyMarkdown}
|
|
200
|
-
/>
|
|
201
|
-
</DocsLayout.ContentHeader>
|
|
202
|
-
)}
|
|
203
|
-
|
|
204
|
-
<ErrorBoundary>{children}</ErrorBoundary>
|
|
205
|
-
|
|
206
|
-
{isDocs && (
|
|
207
|
-
<DocsLayout.ContentFooter>
|
|
208
|
-
<PageNav />
|
|
209
|
-
</DocsLayout.ContentFooter>
|
|
210
|
-
)}
|
|
211
|
-
</DocsLayout.ContentMdx>
|
|
212
|
-
</DocsLayout.Content>
|
|
213
|
-
|
|
214
|
-
{isDocs && (
|
|
215
|
-
<OnThisPage
|
|
216
|
-
headings={currentRoute?.headings}
|
|
217
|
-
editLink={config.theme?.editLink}
|
|
218
|
-
communityHelp={config.theme?.communityHelp}
|
|
219
|
-
filePath={currentRoute?.filePath}
|
|
220
|
-
/>
|
|
221
|
-
)}
|
|
222
|
-
</DocsLayout.Body>
|
|
223
|
-
</DocsLayout>
|
|
224
|
-
)
|
|
225
|
-
}
|
|
226
|
-
`;
|
|
227
|
-
}
|
|
228
|
-
function generateHomePage() {
|
|
229
|
-
return `
|
|
230
|
-
import { Button, Cards, Card } from 'boltdocs/client'
|
|
231
|
-
import { time } from 'node:console';
|
|
232
|
-
|
|
233
|
-
const features = [
|
|
234
|
-
{
|
|
235
|
-
title: 'Fast and Lightweight',
|
|
236
|
-
description: 'Boltdocs is built with performance in mind, ensuring your documentation loads quickly and efficiently.',
|
|
237
|
-
icon: '⚡',
|
|
238
|
-
href: "https://boltdocs.vercel.app/docs/guides/overview/introduction"
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
title: "I18n & Versioning Support",
|
|
242
|
-
description: "Easily manage multiple languages and versions of your documentation with built-in support.",
|
|
243
|
-
icon: '🌐',
|
|
244
|
-
href: 'https://boltdocs.vercel.app/docs/guides/core-concepts/i18n'
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
title: 'Customizable',
|
|
248
|
-
description: 'Tailor your documentation site to your needs with flexible customization options.',
|
|
249
|
-
icon: '🎨',
|
|
250
|
-
href: 'https://boltdocs.vercel.app/docs/guides/customization/theme'
|
|
251
|
-
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
title: "plugins",
|
|
255
|
-
description: "Extend Boltdocs' functionality with a growing ecosystem of plugins.",
|
|
256
|
-
icon: '🔌',
|
|
257
|
-
href: 'https://boltdocs.vercel.app/docs/plugins'
|
|
258
|
-
}
|
|
259
|
-
]
|
|
260
|
-
|
|
261
|
-
export default function HomePage() {
|
|
262
|
-
return (
|
|
263
|
-
<div className="w-full h-screen flex flex-col items-center pt-10 gap-6">
|
|
264
|
-
<header className='flex flex-col items-center'>
|
|
265
|
-
<h1 className="text-4xl font-bold text-center">Powerful Documentation</h1>
|
|
266
|
-
<p className="text-center">
|
|
267
|
-
Your minimal documentation site is ready. Start building something amazing.
|
|
268
|
-
</p>
|
|
269
|
-
<div className="flex gap-4">
|
|
270
|
-
<Button href="/docs">
|
|
271
|
-
Get Started
|
|
272
|
-
</Button>
|
|
273
|
-
</div>
|
|
274
|
-
</header>
|
|
275
|
-
<Cards className='mx-auto w-[60%]' cols={2}>
|
|
276
|
-
{features.map((feature, index) => (
|
|
277
|
-
<Card href={feature.href} key={index} title={feature.title} icon={feature.icon}>
|
|
278
|
-
<p>{feature.description}</p>
|
|
279
|
-
</Card>
|
|
280
|
-
))}
|
|
281
|
-
</Cards>
|
|
282
|
-
</div>
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
`;
|
|
286
|
-
}
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region src/templates/empty.ts
|
|
289
|
-
function generateEmptyTemplate(projectDir, projectName) {
|
|
290
|
-
const srcDir = node_path.default.join(projectDir, "src");
|
|
291
|
-
node_fs.default.mkdirSync(srcDir, { recursive: true });
|
|
292
|
-
const docsDir = node_path.default.join(projectDir, "docs");
|
|
293
|
-
node_fs.default.mkdirSync(docsDir, { recursive: true });
|
|
294
|
-
node_fs.default.writeFileSync(node_path.default.join(srcDir, "home-page.tsx"), generateHomePage());
|
|
295
|
-
node_fs.default.writeFileSync(node_path.default.join(projectDir, "index.css"), getIndexCss());
|
|
296
|
-
node_fs.default.writeFileSync(node_path.default.join(docsDir, "layout.tsx"), getLayoutPage());
|
|
297
|
-
const indexMdx = `---
|
|
298
|
-
title: Welcome
|
|
299
|
-
---
|
|
300
|
-
|
|
301
|
-
# Welcome to ${projectName}
|
|
302
|
-
|
|
303
|
-
This is a minimal documentation setup. You can start by editing \`docs/index.mdx\`.
|
|
304
|
-
`;
|
|
305
|
-
node_fs.default.writeFileSync(node_path.default.join(docsDir, "index.mdx"), indexMdx);
|
|
306
|
-
}
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/templates/base.ts
|
|
309
|
-
function generateBaseTemplate(projectDir, projectName) {
|
|
310
|
-
const srcDir = node_path.default.join(projectDir, "src");
|
|
311
|
-
node_fs.default.mkdirSync(srcDir, { recursive: true });
|
|
312
|
-
const componentsDir = node_path.default.join(srcDir, "components");
|
|
313
|
-
node_fs.default.mkdirSync(componentsDir, { recursive: true });
|
|
314
|
-
node_fs.default.writeFileSync(node_path.default.join(componentsDir, "Button.tsx"), `import React from 'react';
|
|
315
|
-
|
|
316
|
-
export function Button({ children, ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) {
|
|
317
|
-
return (
|
|
318
|
-
<button
|
|
319
|
-
{...props}
|
|
320
|
-
className={'px-6 py-3 rounded-lg bg-primary text-primary-foreground cursor-pointer font-bold transition-opacity hover:opacity-90 ' + (props.className || '')}
|
|
321
|
-
>
|
|
322
|
-
{children}
|
|
323
|
-
</button>
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
`);
|
|
327
|
-
const docsDir = node_path.default.join(projectDir, "docs");
|
|
328
|
-
node_fs.default.mkdirSync(docsDir, { recursive: true });
|
|
329
|
-
node_fs.default.writeFileSync(node_path.default.join(srcDir, "home-page.tsx"), generateHomePage());
|
|
330
|
-
node_fs.default.writeFileSync(node_path.default.join(docsDir, "layout.tsx"), getLayoutPage());
|
|
331
|
-
node_fs.default.writeFileSync(node_path.default.join(projectDir, "index.css"), getIndexCss());
|
|
332
|
-
node_fs.default.writeFileSync(node_path.default.join(docsDir, "index.mdx"), `---
|
|
333
|
-
title: Introduction
|
|
334
|
-
---
|
|
335
|
-
|
|
336
|
-
# Introduction
|
|
337
|
-
|
|
338
|
-
Welcome to your new documentation site!
|
|
339
|
-
|
|
340
|
-
## Features
|
|
341
|
-
|
|
342
|
-
- **Beautiful Design**: Modern and clean interface.
|
|
343
|
-
- **Custom Components**: Use React in your markdown.
|
|
344
|
-
- **Fast**: Optimized for speed and performance.
|
|
345
|
-
|
|
346
|
-
<Tip>
|
|
347
|
-
You can find this component in \`src/components/Button.tsx\`.
|
|
348
|
-
</Tip>
|
|
349
|
-
|
|
350
|
-
<Button onClick={() => alert('Hello world!')}>Try me</Button>
|
|
351
|
-
`);
|
|
352
|
-
}
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region src/templates/i18n.ts
|
|
355
|
-
function generateI18nTemplate(projectDir, projectName) {
|
|
356
|
-
const srcDir = node_path.default.join(projectDir, "src");
|
|
357
|
-
node_fs.default.mkdirSync(srcDir, { recursive: true });
|
|
358
|
-
const componentsDir = node_path.default.join(srcDir, "components");
|
|
359
|
-
node_fs.default.mkdirSync(componentsDir, { recursive: true });
|
|
360
|
-
node_fs.default.writeFileSync(node_path.default.join(componentsDir, "Button.tsx"), `import React from 'react';
|
|
361
|
-
|
|
362
|
-
export function Button({ children, className = '', ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) {
|
|
363
|
-
return (
|
|
364
|
-
<button
|
|
365
|
-
className={\`bg-primary text-primary-foreground px-6 py-3 rounded-lg font-bold hover:opacity-90 transition-all cursor-pointer \${className}\`}
|
|
366
|
-
{...props}
|
|
367
|
-
>
|
|
368
|
-
{children}
|
|
369
|
-
</button>
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
`);
|
|
373
|
-
const docsDir = node_path.default.join(projectDir, "docs");
|
|
374
|
-
node_fs.default.mkdirSync(docsDir, { recursive: true });
|
|
375
|
-
node_fs.default.writeFileSync(node_path.default.join(srcDir, "home-page.tsx"), generateHomePage());
|
|
376
|
-
node_fs.default.writeFileSync(node_path.default.join(projectDir, "index.css"), getIndexCss());
|
|
377
|
-
node_fs.default.writeFileSync(node_path.default.join(docsDir, "layout.tsx"), getLayoutPage());
|
|
378
|
-
node_fs.default.writeFileSync(node_path.default.join(docsDir, "index.mdx"), `---
|
|
379
|
-
title: Introduction
|
|
380
|
-
---
|
|
381
|
-
|
|
382
|
-
# Internationalization
|
|
383
|
-
|
|
384
|
-
This project is configured with English and Spanish support.
|
|
385
|
-
|
|
386
|
-
Check the \`es/\` folder for Spanish content.
|
|
387
|
-
`);
|
|
388
|
-
const esDocsDir = node_path.default.join(docsDir, "es");
|
|
389
|
-
node_fs.default.mkdirSync(esDocsDir, { recursive: true });
|
|
390
|
-
node_fs.default.writeFileSync(node_path.default.join(esDocsDir, "index.mdx"), `---
|
|
391
|
-
title: Introducción
|
|
392
|
-
---
|
|
393
|
-
|
|
394
|
-
# Internacionalización
|
|
395
|
-
|
|
396
|
-
Este proyecto está configurado con soporte para Inglés y Español.
|
|
397
|
-
|
|
398
|
-
Boltdocs detecta automáticamente las carpetas de idiomas.
|
|
399
|
-
`);
|
|
400
|
-
}
|
|
401
|
-
//#endregion
|
|
402
|
-
//#region src/templates/external.ts
|
|
403
|
-
function generateExternalTemplate(projectDir, projectName) {
|
|
404
|
-
const srcDir = node_path.default.join(projectDir, "src");
|
|
405
|
-
node_fs.default.mkdirSync(srcDir, { recursive: true });
|
|
406
|
-
const docsDir = node_path.default.join(projectDir, "docs");
|
|
407
|
-
node_fs.default.mkdirSync(docsDir, { recursive: true });
|
|
408
|
-
const externalPagesDir = node_path.default.join(docsDir, "pages-external");
|
|
409
|
-
node_fs.default.mkdirSync(externalPagesDir, { recursive: true });
|
|
410
|
-
node_fs.default.writeFileSync(node_path.default.join(externalPagesDir, "index.tsx"), `import React from 'react'
|
|
411
|
-
import { PrimitiveButton } from 'boltdocs/client'
|
|
412
|
-
import HomePage from '../../src/home-page'
|
|
413
|
-
|
|
414
|
-
export const homePage = HomePage
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* External pages are standalone React components mapped to specific routes.
|
|
418
|
-
* They are defined outside the standard docs/ hierarchy.
|
|
419
|
-
*/
|
|
420
|
-
export const pages = {
|
|
421
|
-
'/contact': () => (
|
|
422
|
-
<div className="p-20 text-center">
|
|
423
|
-
<h1 className="text-6xl font-black mb-6 bg-linear-to-r from-primary-600 to-primary-400 bg-clip-text text-transparent">
|
|
424
|
-
Contact Us
|
|
425
|
-
</h1>
|
|
426
|
-
<p className="text-xl text-text-muted mb-12 max-w-2xl mx-auto leading-relaxed">
|
|
427
|
-
This is a custom page defined in pages-external/index.tsx.
|
|
428
|
-
It bypassing the standard markdown processing while still being part of your Boltdocs app.
|
|
429
|
-
</p>
|
|
430
|
-
<PrimitiveButton
|
|
431
|
-
onClick={() => window.location.href = '/'}
|
|
432
|
-
className="px-8 py-4 text-lg"
|
|
433
|
-
>
|
|
434
|
-
Return Home
|
|
435
|
-
</PrimitiveButton>
|
|
436
|
-
</div>
|
|
437
|
-
)
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Custom layout specifically for external pages.
|
|
442
|
-
* If not provided, it will fallback to the default app layout.
|
|
443
|
-
*/
|
|
444
|
-
export const layout = ({ children }: { children: React.ReactNode }) => (
|
|
445
|
-
<div className="min-h-screen bg-bg-main text-text-main flex flex-col">
|
|
446
|
-
<header className="p-6 border-b border-border-subtle bg-bg-surface/50 backdrop-blur-md sticky top-0 z-50">
|
|
447
|
-
<div className="max-w-7xl mx-auto flex justify-between items-center">
|
|
448
|
-
<div className="font-black text-2xl tracking-tight">BOLTDOCS <span className="text-primary-500 text-sm font-medium">EXTERNAL</span></div>
|
|
449
|
-
<nav className="flex gap-6 items-center">
|
|
450
|
-
<a href="/" className="text-sm font-medium hover:text-primary-500 transition-colors">Home</a>
|
|
451
|
-
<a href="/docs" className="text-sm font-medium hover:text-primary-500 transition-colors">Documentation</a>
|
|
452
|
-
</nav>
|
|
453
|
-
</div>
|
|
454
|
-
</header>
|
|
455
|
-
<main className="flex-1">
|
|
456
|
-
{children}
|
|
457
|
-
</main>
|
|
458
|
-
<footer className="p-12 border-t border-border-subtle bg-bg-muted/30">
|
|
459
|
-
<div className="max-w-7xl mx-auto text-center">
|
|
460
|
-
<p className="text-sm text-text-muted font-medium italic">
|
|
461
|
-
"The best way to predict the future is to documenting it."
|
|
462
|
-
</p>
|
|
463
|
-
</div>
|
|
464
|
-
</footer>
|
|
465
|
-
</div>
|
|
466
|
-
)
|
|
467
|
-
`);
|
|
468
|
-
node_fs.default.writeFileSync(node_path.default.join(srcDir, "home-page.tsx"), generateHomePage());
|
|
469
|
-
node_fs.default.writeFileSync(node_path.default.join(projectDir, "index.css"), getIndexCss());
|
|
470
|
-
node_fs.default.writeFileSync(node_path.default.join(docsDir, "index.mdx"), `---
|
|
471
|
-
title: Introduction
|
|
472
|
-
---
|
|
473
|
-
|
|
474
|
-
# External Pages Feature
|
|
475
|
-
|
|
476
|
-
This project demonstrates the \`pages-external\` feature of Boltdocs.
|
|
477
|
-
|
|
478
|
-
Check out [Contact Page](/contact) to see it in action.
|
|
479
|
-
|
|
480
|
-
The source code for that page is located in \`docs/pages-external/index.tsx\`.
|
|
481
|
-
`);
|
|
482
|
-
}
|
|
483
|
-
//#endregion
|
|
484
34
|
//#region src/index.ts
|
|
485
35
|
const { green, yellow, bold, cyan, magenta, blue, red, dim } = picocolors.default;
|
|
486
36
|
function getPackageManager() {
|
|
@@ -490,6 +40,19 @@ function getPackageManager() {
|
|
|
490
40
|
if (userAgent?.includes("bun")) return "bun";
|
|
491
41
|
return "npm";
|
|
492
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Recursively copies a directory and replaces placeholders in text files.
|
|
45
|
+
*/
|
|
46
|
+
function copy(src, dest, replacements) {
|
|
47
|
+
if (node_fs.default.statSync(src).isDirectory()) {
|
|
48
|
+
node_fs.default.mkdirSync(dest, { recursive: true });
|
|
49
|
+
for (const file of node_fs.default.readdirSync(src)) copy(node_path.default.resolve(src, file), node_path.default.resolve(dest, file), replacements);
|
|
50
|
+
} else if (!/\.(png|jpg|jpeg|gif|webp|ico|pdf|zip|gz)$/i.test(src)) {
|
|
51
|
+
let content = node_fs.default.readFileSync(src, "utf-8");
|
|
52
|
+
for (const [key, value] of Object.entries(replacements)) content = content.replace(new RegExp(`{{${key}}}`, "g"), value);
|
|
53
|
+
node_fs.default.writeFileSync(dest, content);
|
|
54
|
+
} else node_fs.default.copyFileSync(src, dest);
|
|
55
|
+
}
|
|
493
56
|
async function run() {
|
|
494
57
|
const pkgManager = getPackageManager();
|
|
495
58
|
console.log(blue(bold(`
|
|
@@ -498,7 +61,7 @@ async function run() {
|
|
|
498
61
|
| _ \\| | | | | | | | | | | | | | | \\___ \\
|
|
499
62
|
| |_) | |_| | |___ | | | |_| | |_| | |___ ___) |
|
|
500
63
|
|____/ \\___/|_____| |_| |____/ \\___/ \\____|____/`)));
|
|
501
|
-
console.log(dim(`\n v0.0.
|
|
64
|
+
console.log(dim(`\n v0.0.4 - The modern documentation framework\n`));
|
|
502
65
|
const response = await (0, prompts.default)([
|
|
503
66
|
{
|
|
504
67
|
type: "text",
|
|
@@ -510,29 +73,16 @@ async function run() {
|
|
|
510
73
|
type: "select",
|
|
511
74
|
name: "template",
|
|
512
75
|
message: "Select a project preset:",
|
|
513
|
-
choices: [
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
title: yellow("i18n"),
|
|
526
|
-
description: "Multi-language support (EN/ES).",
|
|
527
|
-
value: "i18n"
|
|
528
|
-
},
|
|
529
|
-
{
|
|
530
|
-
title: blue("External"),
|
|
531
|
-
description: "Custom routes and external layouts.",
|
|
532
|
-
value: "external"
|
|
533
|
-
}
|
|
534
|
-
],
|
|
535
|
-
initial: 1
|
|
76
|
+
choices: [{
|
|
77
|
+
title: magenta("Base"),
|
|
78
|
+
description: "Hero and custom components.",
|
|
79
|
+
value: "base"
|
|
80
|
+
}, {
|
|
81
|
+
title: yellow("i18n"),
|
|
82
|
+
description: "Multi-language support (EN/ES).",
|
|
83
|
+
value: "i18n"
|
|
84
|
+
}],
|
|
85
|
+
initial: 0
|
|
536
86
|
},
|
|
537
87
|
{
|
|
538
88
|
type: "confirm",
|
|
@@ -551,27 +101,22 @@ async function run() {
|
|
|
551
101
|
process.exit(1);
|
|
552
102
|
}
|
|
553
103
|
console.log(dim(`\nBuilding your documentation site...\n`));
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const publicDir = node_path.default.join(projectDir, "public");
|
|
571
|
-
node_fs.default.mkdirSync(publicDir, { recursive: true });
|
|
572
|
-
node_fs.default.writeFileSync(node_path.default.join(publicDir, "logo-light.svg"), getLogoLight());
|
|
573
|
-
node_fs.default.writeFileSync(node_path.default.join(publicDir, "logo-dark.svg"), getLogoDark());
|
|
574
|
-
console.log(`${green("✔")} Finalized configuration and assets`);
|
|
104
|
+
const __dirname = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
105
|
+
const templateDir = node_path.default.resolve(__dirname, "templates", response.template);
|
|
106
|
+
if (!node_fs.default.existsSync(templateDir)) {
|
|
107
|
+
console.error(red(`\nError: Template "${response.template}" not found at ${templateDir}`));
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
copy(templateDir, projectDir, {
|
|
112
|
+
name: response.projectName,
|
|
113
|
+
title: response.projectName
|
|
114
|
+
});
|
|
115
|
+
console.log(`${green("✔")} Created project structure and applied "${response.template}" preset`);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error(red(`\nError copying template: ${error instanceof Error ? error.message : String(error)}`));
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
575
120
|
if (response.install) {
|
|
576
121
|
console.log(cyan(`\nInstalling dependencies with ${pkgManager}...\n`));
|
|
577
122
|
try {
|