create-boltdocs 0.1.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.
Files changed (34) hide show
  1. package/dist/index.cjs +120 -728
  2. package/dist/index.d.cts +1 -1
  3. package/dist/index.d.mts +1 -0
  4. package/dist/index.mjs +114 -0
  5. package/dist/templates/base/boltdocs.config.ts +35 -0
  6. package/dist/templates/base/docs/getting-started/index.md +33 -0
  7. package/dist/templates/base/docs/layout.tsx +78 -0
  8. package/dist/templates/base/docs/pages-external/index.tsx +23 -0
  9. package/dist/templates/base/index.css +12 -0
  10. package/dist/templates/base/index.html +11 -0
  11. package/dist/templates/base/package.json +25 -0
  12. package/dist/templates/base/public/dark.svg +4 -0
  13. package/dist/templates/base/public/light.svg +4 -0
  14. package/dist/templates/base/src/components/footer.tsx +7 -0
  15. package/dist/templates/base/src/pages/home.tsx +43 -0
  16. package/dist/templates/base/tsconfig.json +22 -0
  17. package/dist/templates/base/tsconfig.node.json +10 -0
  18. package/dist/templates/i18n/boltdocs.config.ts +39 -0
  19. package/dist/templates/i18n/docs/es/getting-started/index.md +33 -0
  20. package/dist/templates/i18n/docs/getting-started/index.md +33 -0
  21. package/dist/templates/i18n/docs/layout.tsx +80 -0
  22. package/dist/templates/i18n/docs/pages-external/index.tsx +23 -0
  23. package/dist/templates/i18n/index.css +12 -0
  24. package/dist/templates/i18n/index.html +11 -0
  25. package/dist/templates/i18n/package.json +25 -0
  26. package/dist/templates/i18n/public/dark.svg +4 -0
  27. package/dist/templates/i18n/public/light.svg +4 -0
  28. package/dist/templates/i18n/src/components/footer.tsx +15 -0
  29. package/dist/templates/i18n/src/pages/home.tsx +43 -0
  30. package/dist/templates/i18n/tsconfig.json +22 -0
  31. package/dist/templates/i18n/tsconfig.node.json +10 -0
  32. package/package.json +6 -6
  33. package/dist/index.d.ts +0 -1
  34. package/dist/index.js +0 -724
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
2
+ //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,741 +7,133 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
16
18
  };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
-
26
- // src/index.ts
27
- var import_node_fs5 = __toESM(require("fs"), 1);
28
- var import_node_path5 = __toESM(require("path"), 1);
29
- var import_node_child_process = require("child_process");
30
- var import_prompts = __toESM(require("prompts"), 1);
31
- var import_picocolors = __toESM(require("picocolors"), 1);
32
-
33
- // 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 "**/*.{md,mdx}"',
46
- "lint:md:fix": 'markdownlint-cli2 --fix "**/*.{md,mdx}"'
47
- },
48
- dependencies: {
49
- react: "^19.0.0",
50
- "react-dom": "^19.0.0",
51
- boltdocs: "latest"
52
- },
53
- devDependencies: {
54
- typescript: "^5.7.0",
55
- "@types/react": "^19.0.0",
56
- "@types/react-dom": "^19.0.0",
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
- var gitignoreContent = `node_modules
65
- dist
66
- .DS_Store
67
- .boltdocs
68
- `;
69
- var 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
- var 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\xF1ol'
115
- },
116
- localeConfigs: {
117
- en: { label: 'English', direction: 'ltr' },
118
- es: { label: 'Espa\xF1ol', direction: 'ltr' }
119
- }
120
- },` : "";
121
- const homePageConfig = options.homePage ? `
122
- homePage: '${options.homePage}',` : "";
123
- return `import { defineConfig } from 'boltdocs';
124
-
125
- export default defineConfig({${homePageConfig}${i18nConfig}
126
- theme: {
127
- title: '${projectName}',
128
- logo: {
129
- light: '/logo-dark.svg',
130
- dark: '/logo-light.svg',
131
- alt: '${projectName} Logo'
132
- },
133
- navbar: [
134
- { label: 'Home', href: '/' },
135
- { label: 'Documentation', href: '/docs' },
136
- ],
137
- socialLinks: [
138
- { icon: 'github', link: 'https://github.com/jesusalcaladev/boltdocs' }
139
- ]
140
- }
141
- });`;
142
- }
143
- function getIndexCss() {
144
- return `@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");
145
- @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');
146
-
147
- @import "tailwindcss";
148
- @import "boltdocs/theme/neutral.css";
149
-
150
- /*
151
- @source directive tells Tailwind to scan Boltdocs client components
152
- inside node_modules for class usage and generate the necessary CSS.
153
- */
154
- @source "./node_modules/boltdocs/src/client";
155
-
156
- .hero-section {
157
- display: flex;
158
- flex-direction: column;
159
- align-items: center;
160
- justify-content: center;
161
- padding: 8rem 2rem;
162
- text-align: center;
163
- }
164
-
165
- .hero-title {
166
- font-size: 4.5rem;
167
- font-weight: 900;
168
- letter-spacing: -0.02em;
169
- line-height: 1.1;
170
- background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-primary-400) 100%);
171
- -webkit-background-clip: text;
172
- -webkit-text-fill-color: transparent;
173
- margin-bottom: 1.5rem;
174
- }
175
-
176
- .hero-subtitle {
177
- font-size: 1.5rem;
178
- color: var(--color-muted);
179
- max-width: 48rem;
180
- margin-bottom: 3rem;
181
- line-height: 1.6;
182
- }
183
- `;
184
- }
185
- function getLayoutPage() {
186
- return `import {
187
- DocsLayout,
188
- Navbar,
189
- Sidebar,
190
- OnThisPage,
191
- Head,
192
- Breadcrumbs,
193
- PageNav,
194
- ErrorBoundary,
195
- CopyMarkdown,
196
- useRoutes,
197
- useConfig,
198
- useMdxComponents,
199
- useLocation
200
- } from 'boltdocs/client'
201
-
202
- export default function Layout({ children }: { children: React.ReactNode }) {
203
- const { routes: filteredRoutes, allRoutes, currentRoute } = useRoutes()
204
- const { pathname } = useLocation()
205
- const config = useConfig()
206
- const mdxComponents = useMdxComponents()
207
- const CopyMarkdownComp = (mdxComponents.CopyMarkdown as any) || CopyMarkdown
208
-
209
- const isHome = pathname === '/' || pathname === ''
210
-
211
- return (
212
- <DocsLayout>
213
- {/* Modern Spotlight Gradients */}
214
- <Head
215
- siteTitle={config.theme?.title || 'Boltdocs'}
216
- siteDescription={config.theme?.description || ''}
217
- routes={allRoutes}
218
- />
219
- <Navbar />
220
-
221
- <DocsLayout.Body>
222
- {!isHome && <Sidebar routes={filteredRoutes} config={config} />}
223
-
224
- <DocsLayout.Content>
225
- {!isHome && (
226
- <DocsLayout.ContentHeader>
227
- <Breadcrumbs />
228
- <CopyMarkdownComp
229
- mdxRaw={currentRoute?._rawContent}
230
- route={currentRoute}
231
- config={config.theme?.copyMarkdown}
232
- />
233
- </DocsLayout.ContentHeader>
234
- )}
235
-
236
- <ErrorBoundary>{children}</ErrorBoundary>
237
-
238
- {!isHome && (
239
- <DocsLayout.ContentFooter>
240
- <PageNav />
241
- </DocsLayout.ContentFooter>
242
- )}
243
- </DocsLayout.Content>
244
-
245
- {!isHome && (
246
- <OnThisPage
247
- headings={currentRoute?.headings}
248
- editLink={config.theme?.editLink}
249
- communityHelp={config.theme?.communityHelp}
250
- filePath={currentRoute?.filePath}
251
- />
252
- )}
253
- </DocsLayout.Body>
254
- </DocsLayout>
255
- )
256
- }
257
-
258
- `;
259
- }
260
-
261
- // src/templates/empty.ts
262
- var import_node_path = __toESM(require("path"), 1);
263
- var import_node_fs = __toESM(require("fs"), 1);
264
- function generateEmptyTemplate(projectDir, projectName) {
265
- const srcDir = import_node_path.default.join(projectDir, "src");
266
- import_node_fs.default.mkdirSync(srcDir, { recursive: true });
267
- const homePageContent = `import React from 'react';
268
-
269
- export default function HomePage() {
270
- return (
271
- <div className="hero-section">
272
- <h1 className="hero-title">${projectName}</h1>
273
- <p className="hero-subtitle">
274
- Your minimal documentation site is ready. Start building something amazing.
275
- </p>
276
- <div className="flex gap-4">
277
- <a href="/docs" className="bg-primary text-primary-foreground px-8 py-3 rounded-lg no-underline font-semibold text-lg hover:opacity-90 transition-opacity">
278
- Get Started
279
- </a>
280
- </div>
281
- </div>
282
- );
283
- }
284
- `;
285
- const docsDir = import_node_path.default.join(projectDir, "docs");
286
- import_node_fs.default.mkdirSync(docsDir, { recursive: true });
287
- import_node_fs.default.writeFileSync(import_node_path.default.join(srcDir, "HomePage.tsx"), homePageContent);
288
- import_node_fs.default.writeFileSync(import_node_path.default.join(projectDir, "index.css"), getIndexCss());
289
- import_node_fs.default.writeFileSync(import_node_path.default.join(docsDir, "layout.tsx"), getLayoutPage());
290
- const indexMdx = `---
291
- title: Welcome
292
- ---
293
-
294
- # Welcome to ${projectName}
295
-
296
- This is a minimal documentation setup. You can start by editing \`docs/index.mdx\`.
297
- `;
298
- import_node_fs.default.writeFileSync(import_node_path.default.join(docsDir, "index.mdx"), indexMdx);
299
- }
300
-
301
- // src/templates/base.ts
302
- var import_node_path2 = __toESM(require("path"), 1);
303
- var import_node_fs2 = __toESM(require("fs"), 1);
304
- function generateBaseTemplate(projectDir) {
305
- const srcDir = import_node_path2.default.join(projectDir, "src");
306
- import_node_fs2.default.mkdirSync(srcDir, { recursive: true });
307
- const componentsDir = import_node_path2.default.join(srcDir, "components");
308
- import_node_fs2.default.mkdirSync(componentsDir, { recursive: true });
309
- const buttonContent = `import React from 'react';
310
-
311
- export function Button({ children, ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) {
312
- return (
313
- <button
314
- {...props}
315
- className={'px-6 py-3 rounded-lg bg-primary text-primary-foreground cursor-pointer font-bold transition-opacity hover:opacity-90 ' + (props.className || '')}
316
- >
317
- {children}
318
- </button>
319
- );
320
- }
321
- `;
322
- import_node_fs2.default.writeFileSync(import_node_path2.default.join(componentsDir, "Button.tsx"), buttonContent);
323
- const homePageContent = `import { Button, Cards, Card } from 'boltdocs/client';
324
-
325
- export default function HomePage() {
326
- return (
327
- <div className="hero-section">
328
- <h1 className="hero-title">my-boltdocs-app</h1>
329
- <p className="hero-subtitle">
330
- The modern documentation framework. Fast, efficient, and beautiful by default.
331
- </p>
332
-
333
- <div className="flex gap-4 mb-16">
334
- <Button href="/docs">
335
- Get Started
336
- </Button>
337
- <Button href="https://github.com/jesusalcaladev/boltdocs" variant={'ghost'}>
338
- GitHub
339
- </Button>
340
- </div>
341
-
342
- <Cards>
343
- {[
344
- {
345
- title: "Performance First",
346
- desc: "Ultra-fast load times and instant HMR with Vite-powered development."
347
- },
348
- {
349
- title: "MDX Support",
350
- desc: "Write documentation with React components directly in your markdown files."
351
- },
352
- {
353
- title: "Fully Customizable",
354
- desc: "Custom layouts, components, and themes tailored to your project needs."
355
- }
356
- ].map((feat, i) => (
357
- <Card key={i} title={feat.title}>
358
- {feat.desc}
359
- </Card>
360
- ))}
361
- </Cards>
362
- </div>
363
- );
364
- }
365
-
366
- `;
367
- const docsDir = import_node_path2.default.join(projectDir, "docs");
368
- import_node_fs2.default.mkdirSync(docsDir, { recursive: true });
369
- import_node_fs2.default.writeFileSync(import_node_path2.default.join(srcDir, "home-page.tsx"), homePageContent);
370
- import_node_fs2.default.writeFileSync(import_node_path2.default.join(docsDir, "layout.tsx"), getLayoutPage());
371
- import_node_fs2.default.writeFileSync(import_node_path2.default.join(projectDir, "index.css"), getIndexCss());
372
- const indexMdx = `---
373
- title: Introduction
374
- ---
375
-
376
- # Introduction
377
-
378
- Welcome to your new documentation site!
379
-
380
- ## Features
381
-
382
- - **Beautiful Design**: Modern and clean interface.
383
- - **Custom Components**: Use React in your markdown.
384
- - **Fast**: Optimized for speed and performance.
385
-
386
- <Tip>
387
- You can find this component in \`src/components/Button.tsx\`.
388
- </Tip>
389
-
390
- <Button onClick={() => alert('Hello world!')}>Try me</Button>
391
- `;
392
- import_node_fs2.default.writeFileSync(import_node_path2.default.join(docsDir, "index.mdx"), indexMdx);
393
- }
394
-
395
- // src/templates/i18n.ts
396
- var import_node_path3 = __toESM(require("path"), 1);
397
- var import_node_fs3 = __toESM(require("fs"), 1);
398
- function generateI18nTemplate(projectDir) {
399
- const srcDir = import_node_path3.default.join(projectDir, "src");
400
- import_node_fs3.default.mkdirSync(srcDir, { recursive: true });
401
- const componentsDir = import_node_path3.default.join(srcDir, "components");
402
- import_node_fs3.default.mkdirSync(componentsDir, { recursive: true });
403
- const buttonContent = `import React from 'react';
404
-
405
- export function Button({ children, className = '', ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) {
406
- return (
407
- <button
408
- className={\`bg-primary text-primary-foreground px-6 py-3 rounded-lg font-bold hover:opacity-90 transition-all cursor-pointer \${className}\`}
409
- {...props}
410
- >
411
- {children}
412
- </button>
413
- );
414
- }
415
- `;
416
- import_node_fs3.default.writeFileSync(import_node_path3.default.join(componentsDir, "Button.tsx"), buttonContent);
417
- const homePageContent = `import React from 'react';
418
- import { Button } from './components/Button';
419
- import { useI18n } from 'boltdocs/client';
420
-
421
- export default function HomePage() {
422
- const { currentLocale } = useI18n();
423
- const locale = currentLocale || 'en';
424
-
425
- const translations: any = {
426
- en: {
427
- title: "Global Documentation",
428
- subtitle: "Multi-language support built-in.",
429
- button: "Get Started"
430
- },
431
- es: {
432
- title: "Documentaci\xF3n Global",
433
- subtitle: "Soporte multi-idioma integrado.",
434
- button: "Comenzar"
435
- }
436
- };
437
-
438
- const content = translations[locale] || translations.en;
439
-
440
- return (
441
- <div className="hero-section">
442
- <h1 className="hero-title">{content.title}</h1>
443
- <p className="hero-subtitle">{content.subtitle}</p>
444
- <div className="flex gap-4">
445
- <a href="/docs" className="no-underline">
446
- <Button className="text-lg px-10 py-4">
447
- {content.button}
448
- </Button>
449
- </a>
450
- </div>
451
- </div>
452
- );
453
- }
454
- `;
455
- const docsDir = import_node_path3.default.join(projectDir, "docs");
456
- import_node_fs3.default.mkdirSync(docsDir, { recursive: true });
457
- import_node_fs3.default.writeFileSync(import_node_path3.default.join(srcDir, "home-page.tsx"), homePageContent);
458
- import_node_fs3.default.writeFileSync(import_node_path3.default.join(projectDir, "index.css"), getIndexCss());
459
- import_node_fs3.default.writeFileSync(import_node_path3.default.join(docsDir, "layout.tsx"), getLayoutPage());
460
- import_node_fs3.default.writeFileSync(
461
- import_node_path3.default.join(docsDir, "index.mdx"),
462
- `---
463
- title: Introduction
464
- ---
465
-
466
- # Internationalization
467
-
468
- This project is configured with English and Spanish support.
469
-
470
- Check the \`es/\` folder for Spanish content.
471
- `
472
- );
473
- const esDocsDir = import_node_path3.default.join(docsDir, "es");
474
- import_node_fs3.default.mkdirSync(esDocsDir, { recursive: true });
475
- import_node_fs3.default.writeFileSync(
476
- import_node_path3.default.join(esDocsDir, "index.mdx"),
477
- `---
478
- title: Introducci\xF3n
479
- ---
480
-
481
- # Internacionalizaci\xF3n
482
-
483
- Este proyecto est\xE1 configurado con soporte para Ingl\xE9s y Espa\xF1ol.
484
-
485
- Boltdocs detecta autom\xE1ticamente las carpetas de idiomas.
486
- `
487
- );
488
- }
489
-
490
- // src/templates/external.ts
491
- var import_node_path4 = __toESM(require("path"), 1);
492
- var import_node_fs4 = __toESM(require("fs"), 1);
493
- function generateExternalTemplate(projectDir) {
494
- const srcDir = import_node_path4.default.join(projectDir, "src");
495
- import_node_fs4.default.mkdirSync(srcDir, { recursive: true });
496
- const docsDir = import_node_path4.default.join(projectDir, "docs");
497
- import_node_fs4.default.mkdirSync(docsDir, { recursive: true });
498
- const externalPagesDir = import_node_path4.default.join(docsDir, "pages-external");
499
- import_node_fs4.default.mkdirSync(externalPagesDir, { recursive: true });
500
- const externalPagesContent = `import React from 'react'
501
- import { PrimitiveButton } from 'boltdocs/client'
502
- import HomePage from '../../src/home-page'
503
-
504
- export const homePage = HomePage
505
-
506
- /**
507
- * External pages are standalone React components mapped to specific routes.
508
- * They are defined outside the standard docs/ hierarchy.
509
- */
510
- export const pages = {
511
- '/contact': () => (
512
- <div className="p-20 text-center">
513
- <h1 className="text-6xl font-black mb-6 bg-linear-to-r from-primary-600 to-primary-400 bg-clip-text text-transparent">
514
- Contact Us
515
- </h1>
516
- <p className="text-xl text-text-muted mb-12 max-w-2xl mx-auto leading-relaxed">
517
- This is a custom page defined in pages-external/index.tsx.
518
- It bypassing the standard markdown processing while still being part of your Boltdocs app.
519
- </p>
520
- <PrimitiveButton
521
- onClick={() => window.location.href = '/'}
522
- className="px-8 py-4 text-lg"
523
- >
524
- Return Home
525
- </PrimitiveButton>
526
- </div>
527
- )
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let node_fs = require("node:fs");
25
+ node_fs = __toESM(node_fs);
26
+ let node_path = require("node:path");
27
+ node_path = __toESM(node_path);
28
+ let node_url = require("node:url");
29
+ let node_child_process = require("node:child_process");
30
+ let prompts = require("prompts");
31
+ prompts = __toESM(prompts);
32
+ let picocolors = require("picocolors");
33
+ picocolors = __toESM(picocolors);
34
+ //#region src/index.ts
35
+ const { green, yellow, bold, cyan, magenta, blue, red, dim } = picocolors.default;
36
+ function getPackageManager() {
37
+ const userAgent = process.env.npm_config_user_agent;
38
+ if (userAgent?.includes("pnpm")) return "pnpm";
39
+ if (userAgent?.includes("yarn")) return "yarn";
40
+ if (userAgent?.includes("bun")) return "bun";
41
+ return "npm";
528
42
  }
529
-
530
43
  /**
531
- * Custom layout specifically for external pages.
532
- * If not provided, it will fallback to the default app layout.
533
- */
534
- export const layout = ({ children }: { children: React.ReactNode }) => (
535
- <div className="min-h-screen bg-bg-main text-text-main flex flex-col">
536
- <header className="p-6 border-b border-border-subtle bg-bg-surface/50 backdrop-blur-md sticky top-0 z-50">
537
- <div className="max-w-7xl mx-auto flex justify-between items-center">
538
- <div className="font-black text-2xl tracking-tight">BOLTDOCS <span className="text-primary-500 text-sm font-medium">EXTERNAL</span></div>
539
- <nav className="flex gap-6 items-center">
540
- <a href="/" className="text-sm font-medium hover:text-primary-500 transition-colors">Home</a>
541
- <a href="/docs" className="text-sm font-medium hover:text-primary-500 transition-colors">Documentation</a>
542
- </nav>
543
- </div>
544
- </header>
545
- <main className="flex-1">
546
- {children}
547
- </main>
548
- <footer className="p-12 border-t border-border-subtle bg-bg-muted/30">
549
- <div className="max-w-7xl mx-auto text-center">
550
- <p className="text-sm text-text-muted font-medium italic">
551
- "The best way to predict the future is to documenting it."
552
- </p>
553
- </div>
554
- </footer>
555
- </div>
556
- )
557
- `;
558
- import_node_fs4.default.writeFileSync(
559
- import_node_path4.default.join(externalPagesDir, "index.tsx"),
560
- externalPagesContent
561
- );
562
- const homePageContent = `import React from 'react'
563
- import { Button } from 'boltdocs/client'
564
-
565
- export default function HomePage() {
566
- return (
567
- <div className="hero-section">
568
- <h1 className="hero-title text-center">External Pages</h1>
569
- <p className="hero-subtitle text-center">
570
- Boltdocs now supports standalone React pages and custom layouts outside the standard docs structure.
571
- </p>
572
- <div className="flex gap-4">
573
- <a href="/docs" className="no-underline">
574
- <Button className="text-lg px-10 py-4">Read Docs</Button>
575
- </a>
576
- <a href="/contact" className="no-underline">
577
- <Button variant="ghost" className="text-lg px-10 py-4">External Page</Button>
578
- </a>
579
- </div>
580
- </div>
581
- )
582
- }
583
- `;
584
- import_node_fs4.default.writeFileSync(import_node_path4.default.join(srcDir, "home-page.tsx"), homePageContent);
585
- import_node_fs4.default.writeFileSync(import_node_path4.default.join(projectDir, "index.css"), getIndexCss());
586
- import_node_fs4.default.writeFileSync(
587
- import_node_path4.default.join(docsDir, "index.mdx"),
588
- `---
589
- title: Introduction
590
- ---
591
-
592
- # External Pages Feature
593
-
594
- This project demonstrates the \`pages-external\` feature of Boltdocs.
595
-
596
- Check out [Contact Page](/contact) to see it in action.
597
-
598
- The source code for that page is located in \`docs/pages-external/index.tsx\`.
599
- `
600
- );
601
- }
602
-
603
- // src/index.ts
604
- var { green, yellow, bold, cyan, magenta, blue, red, dim } = import_picocolors.default;
605
- function getPackageManager() {
606
- const userAgent = process.env.npm_config_user_agent;
607
- if (userAgent?.includes("pnpm")) return "pnpm";
608
- if (userAgent?.includes("yarn")) return "yarn";
609
- if (userAgent?.includes("bun")) return "bun";
610
- return "npm";
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);
611
55
  }
612
56
  async function run() {
613
- const pkgManager = getPackageManager();
614
- console.log(
615
- blue(
616
- bold(`
57
+ const pkgManager = getPackageManager();
58
+ console.log(blue(bold(`
617
59
  ____ ___ _ _____ ____ ___ ____ ____
618
60
  | __ ) / _ \\| | |_ _| _ \\ / _ \\ / ___/ ___|
619
61
  | _ \\| | | | | | | | | | | | | | | \\___ \\
620
62
  | |_) | |_| | |___ | | | |_| | |_| | |___ ___) |
621
- |____/ \\___/|_____| |_| |____/ \\___/ \\____|____/`)
622
- )
623
- );
624
- console.log(dim(`
625
- v0.0.2 - The modern documentation framework
626
- `));
627
- const response = await (0, import_prompts.default)([
628
- {
629
- type: "text",
630
- name: "projectName",
631
- message: "Project name:",
632
- initial: "my-boltdocs-app"
633
- },
634
- {
635
- type: "select",
636
- name: "template",
637
- message: "Select a project preset:",
638
- choices: [
639
- {
640
- title: cyan("Empty"),
641
- description: "Minimal documentation setup.",
642
- value: "empty"
643
- },
644
- {
645
- title: magenta("Base"),
646
- description: "Hero and custom components.",
647
- value: "base"
648
- },
649
- {
650
- title: yellow("i18n"),
651
- description: "Multi-language support (EN/ES).",
652
- value: "i18n"
653
- },
654
- {
655
- title: blue("External"),
656
- description: "Custom routes and external layouts.",
657
- value: "external"
658
- }
659
- ],
660
- initial: 1
661
- },
662
- {
663
- type: "confirm",
664
- name: "install",
665
- message: `Install dependencies with ${bold(pkgManager)}?`,
666
- initial: true
667
- }
668
- ]);
669
- if (!response.projectName || !response.template) {
670
- console.log(yellow("\nOperation canceled."));
671
- return;
672
- }
673
- const projectDir = import_node_path5.default.join(process.cwd(), response.projectName);
674
- if (import_node_fs5.default.existsSync(projectDir)) {
675
- console.error(
676
- red(`
677
- Error: Directory "${response.projectName}" already exists.`)
678
- );
679
- process.exit(1);
680
- }
681
- console.log(dim(`
682
- Building your documentation site...
683
- `));
684
- import_node_fs5.default.mkdirSync(projectDir, { recursive: true });
685
- console.log(`${green("\u2714")} Created project directory`);
686
- const configOptions = {};
687
- if (response.template === "empty") {
688
- generateEmptyTemplate(projectDir, response.projectName);
689
- } else if (response.template === "i18n") {
690
- configOptions.i18n = true;
691
- configOptions.homePage = "./src/home-page.tsx";
692
- generateI18nTemplate(projectDir);
693
- } else if (response.template === "external") {
694
- generateExternalTemplate(projectDir);
695
- } else {
696
- configOptions.homePage = "./src/home-page.tsx";
697
- generateBaseTemplate(projectDir);
698
- }
699
- console.log(`${green("\u2714")} Applied "${response.template}" preset`);
700
- import_node_fs5.default.writeFileSync(
701
- import_node_path5.default.join(projectDir, "package.json"),
702
- JSON.stringify(getPackageJson(response.projectName), null, 2)
703
- );
704
- import_node_fs5.default.writeFileSync(import_node_path5.default.join(projectDir, ".gitignore"), gitignoreContent);
705
- import_node_fs5.default.writeFileSync(import_node_path5.default.join(projectDir, ".npmignore"), gitignoreContent);
706
- import_node_fs5.default.writeFileSync(
707
- import_node_path5.default.join(projectDir, ".markdownlint.yaml"),
708
- markdownlintContent
709
- );
710
- import_node_fs5.default.writeFileSync(
711
- import_node_path5.default.join(projectDir, ".markdownlintignore"),
712
- markdownlintignoreContent
713
- );
714
- import_node_fs5.default.writeFileSync(
715
- import_node_path5.default.join(projectDir, "boltdocs.config.ts"),
716
- getBoltdocsConfig(response.projectName, configOptions)
717
- );
718
- const publicDir = import_node_path5.default.join(projectDir, "public");
719
- import_node_fs5.default.mkdirSync(publicDir, { recursive: true });
720
- import_node_fs5.default.writeFileSync(import_node_path5.default.join(publicDir, "logo-light.svg"), getLogoLight());
721
- import_node_fs5.default.writeFileSync(import_node_path5.default.join(publicDir, "logo-dark.svg"), getLogoDark());
722
- console.log(`${green("\u2714")} Finalized configuration and assets`);
723
- if (response.install) {
724
- console.log(cyan(`
725
- Installing dependencies with ${pkgManager}...
726
- `));
727
- try {
728
- (0, import_node_child_process.execSync)(`${pkgManager} install`, { cwd: projectDir, stdio: "inherit" });
729
- console.log(`
730
- ${green("\u2714")} Dependencies installed successfully`);
731
- } catch (e) {
732
- console.log(
733
- yellow(
734
- `
735
- Could not install dependencies automatically. Please run "${pkgManager} install".`
736
- )
737
- );
738
- }
739
- }
740
- console.log(bold(green("\n\u2728 All set! Your documentation is ready. \u2728\n")));
741
- console.log(`To start developing:`);
742
- console.log(` cd ${response.projectName}`);
743
- if (!response.install) console.log(` ${pkgManager} install`);
744
- console.log(` ${pkgManager} run dev
745
- `);
63
+ |____/ \\___/|_____| |_| |____/ \\___/ \\____|____/`)));
64
+ console.log(dim(`\n v0.0.4 - The modern documentation framework\n`));
65
+ const response = await (0, prompts.default)([
66
+ {
67
+ type: "text",
68
+ name: "projectName",
69
+ message: "Project name:",
70
+ initial: "my-boltdocs-app"
71
+ },
72
+ {
73
+ type: "select",
74
+ name: "template",
75
+ message: "Select a project preset:",
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
86
+ },
87
+ {
88
+ type: "confirm",
89
+ name: "install",
90
+ message: `Install dependencies with ${bold(pkgManager)}?`,
91
+ initial: true
92
+ }
93
+ ]);
94
+ if (!response.projectName || !response.template) {
95
+ console.log(yellow("\nOperation canceled."));
96
+ return;
97
+ }
98
+ const projectDir = node_path.default.join(process.cwd(), response.projectName);
99
+ if (node_fs.default.existsSync(projectDir)) {
100
+ console.error(red(`\nError: Directory "${response.projectName}" already exists.`));
101
+ process.exit(1);
102
+ }
103
+ console.log(dim(`\nBuilding your documentation site...\n`));
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
+ }
120
+ if (response.install) {
121
+ console.log(cyan(`\nInstalling dependencies with ${pkgManager}...\n`));
122
+ try {
123
+ (0, node_child_process.execSync)(`${pkgManager} install`, {
124
+ cwd: projectDir,
125
+ stdio: "inherit"
126
+ });
127
+ console.log(`\n${green("")} Dependencies installed successfully`);
128
+ } catch (e) {
129
+ console.log(yellow(`\nCould not install dependencies automatically. Please run "${pkgManager} install".`));
130
+ }
131
+ }
132
+ console.log(bold(green("\n✨ All set! Your documentation is ready. ✨\n")));
133
+ console.log(`To start developing:`);
134
+ console.log(` cd ${response.projectName}`);
135
+ if (!response.install) console.log(` ${pkgManager} install`);
136
+ console.log(` ${pkgManager} run dev\n`);
746
137
  }
747
138
  run().catch(console.error);
139
+ //#endregion