create-boltdocs 0.0.1 → 0.1.0
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 +155 -31
- package/dist/index.js +155 -31
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24,8 +24,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/index.ts
|
|
27
|
-
var
|
|
28
|
-
var
|
|
27
|
+
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
28
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
29
29
|
var import_node_child_process = require("child_process");
|
|
30
30
|
var import_prompts = __toESM(require("prompts"), 1);
|
|
31
31
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
@@ -41,6 +41,7 @@ function getPackageJson(projectName) {
|
|
|
41
41
|
dev: "boltdocs",
|
|
42
42
|
build: "boltdocs build",
|
|
43
43
|
preview: "boltdocs preview",
|
|
44
|
+
doctor: "boltdocs doctor",
|
|
44
45
|
"lint:md": 'markdownlint-cli2 "**/*.{md,mdx}"',
|
|
45
46
|
"lint:md:fix": 'markdownlint-cli2 --fix "**/*.{md,mdx}"'
|
|
46
47
|
},
|
|
@@ -111,6 +112,10 @@ function getBoltdocsConfig(projectName, options = {}) {
|
|
|
111
112
|
locales: {
|
|
112
113
|
en: 'English',
|
|
113
114
|
es: 'Espa\xF1ol'
|
|
115
|
+
},
|
|
116
|
+
localeConfigs: {
|
|
117
|
+
en: { label: 'English', direction: 'ltr' },
|
|
118
|
+
es: { label: 'Espa\xF1ol', direction: 'ltr' }
|
|
114
119
|
}
|
|
115
120
|
},` : "";
|
|
116
121
|
const homePageConfig = options.homePage ? `
|
|
@@ -186,14 +191,13 @@ function getLayoutPage() {
|
|
|
186
191
|
Head,
|
|
187
192
|
Breadcrumbs,
|
|
188
193
|
PageNav,
|
|
189
|
-
ProgressBar,
|
|
190
194
|
ErrorBoundary,
|
|
191
195
|
CopyMarkdown,
|
|
192
196
|
useRoutes,
|
|
193
197
|
useConfig,
|
|
194
198
|
useMdxComponents,
|
|
199
|
+
useLocation
|
|
195
200
|
} from 'boltdocs/client'
|
|
196
|
-
import { useLocation} from 'boltdocs/hooks'
|
|
197
201
|
|
|
198
202
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
199
203
|
const { routes: filteredRoutes, allRoutes, currentRoute } = useRoutes()
|
|
@@ -207,7 +211,6 @@ export default function Layout({ children }: { children: React.ReactNode }) {
|
|
|
207
211
|
return (
|
|
208
212
|
<DocsLayout>
|
|
209
213
|
{/* Modern Spotlight Gradients */}
|
|
210
|
-
<ProgressBar />
|
|
211
214
|
<Head
|
|
212
215
|
siteTitle={config.theme?.title || 'Boltdocs'}
|
|
213
216
|
siteDescription={config.theme?.description || ''}
|
|
@@ -317,8 +320,7 @@ export function Button({ children, ...props }: React.ButtonHTMLAttributes<HTMLBu
|
|
|
317
320
|
}
|
|
318
321
|
`;
|
|
319
322
|
import_node_fs2.default.writeFileSync(import_node_path2.default.join(componentsDir, "Button.tsx"), buttonContent);
|
|
320
|
-
const homePageContent = `import { Button } from 'boltdocs/
|
|
321
|
-
import { Cards, Card } from 'boltdocs/mdx'
|
|
323
|
+
const homePageContent = `import { Button, Cards, Card } from 'boltdocs/client';
|
|
322
324
|
|
|
323
325
|
export default function HomePage() {
|
|
324
326
|
return (
|
|
@@ -364,7 +366,7 @@ export default function HomePage() {
|
|
|
364
366
|
`;
|
|
365
367
|
const docsDir = import_node_path2.default.join(projectDir, "docs");
|
|
366
368
|
import_node_fs2.default.mkdirSync(docsDir, { recursive: true });
|
|
367
|
-
import_node_fs2.default.writeFileSync(import_node_path2.default.join(srcDir, "
|
|
369
|
+
import_node_fs2.default.writeFileSync(import_node_path2.default.join(srcDir, "home-page.tsx"), homePageContent);
|
|
368
370
|
import_node_fs2.default.writeFileSync(import_node_path2.default.join(docsDir, "layout.tsx"), getLayoutPage());
|
|
369
371
|
import_node_fs2.default.writeFileSync(import_node_path2.default.join(projectDir, "index.css"), getIndexCss());
|
|
370
372
|
const indexMdx = `---
|
|
@@ -414,11 +416,11 @@ export function Button({ children, className = '', ...props }: React.ButtonHTMLA
|
|
|
414
416
|
import_node_fs3.default.writeFileSync(import_node_path3.default.join(componentsDir, "Button.tsx"), buttonContent);
|
|
415
417
|
const homePageContent = `import React from 'react';
|
|
416
418
|
import { Button } from './components/Button';
|
|
417
|
-
import { useI18n } from 'boltdocs/
|
|
419
|
+
import { useI18n } from 'boltdocs/client';
|
|
418
420
|
|
|
419
421
|
export default function HomePage() {
|
|
420
|
-
const
|
|
421
|
-
const locale =
|
|
422
|
+
const { currentLocale } = useI18n();
|
|
423
|
+
const locale = currentLocale || 'en';
|
|
422
424
|
|
|
423
425
|
const translations: any = {
|
|
424
426
|
en: {
|
|
@@ -452,7 +454,7 @@ export default function HomePage() {
|
|
|
452
454
|
`;
|
|
453
455
|
const docsDir = import_node_path3.default.join(projectDir, "docs");
|
|
454
456
|
import_node_fs3.default.mkdirSync(docsDir, { recursive: true });
|
|
455
|
-
import_node_fs3.default.writeFileSync(import_node_path3.default.join(srcDir, "
|
|
457
|
+
import_node_fs3.default.writeFileSync(import_node_path3.default.join(srcDir, "home-page.tsx"), homePageContent);
|
|
456
458
|
import_node_fs3.default.writeFileSync(import_node_path3.default.join(projectDir, "index.css"), getIndexCss());
|
|
457
459
|
import_node_fs3.default.writeFileSync(import_node_path3.default.join(docsDir, "layout.tsx"), getLayoutPage());
|
|
458
460
|
import_node_fs3.default.writeFileSync(
|
|
@@ -485,6 +487,119 @@ Boltdocs detecta autom\xE1ticamente las carpetas de idiomas.
|
|
|
485
487
|
);
|
|
486
488
|
}
|
|
487
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
|
+
)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
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
|
+
|
|
488
603
|
// src/index.ts
|
|
489
604
|
var { green, yellow, bold, cyan, magenta, blue, red, dim } = import_picocolors.default;
|
|
490
605
|
function getPackageManager() {
|
|
@@ -507,7 +622,7 @@ async function run() {
|
|
|
507
622
|
)
|
|
508
623
|
);
|
|
509
624
|
console.log(dim(`
|
|
510
|
-
v0.0.
|
|
625
|
+
v0.0.2 - The modern documentation framework
|
|
511
626
|
`));
|
|
512
627
|
const response = await (0, import_prompts.default)([
|
|
513
628
|
{
|
|
@@ -535,6 +650,11 @@ async function run() {
|
|
|
535
650
|
title: yellow("i18n"),
|
|
536
651
|
description: "Multi-language support (EN/ES).",
|
|
537
652
|
value: "i18n"
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
title: blue("External"),
|
|
656
|
+
description: "Custom routes and external layouts.",
|
|
657
|
+
value: "external"
|
|
538
658
|
}
|
|
539
659
|
],
|
|
540
660
|
initial: 1
|
|
@@ -550,8 +670,8 @@ async function run() {
|
|
|
550
670
|
console.log(yellow("\nOperation canceled."));
|
|
551
671
|
return;
|
|
552
672
|
}
|
|
553
|
-
const projectDir =
|
|
554
|
-
if (
|
|
673
|
+
const projectDir = import_node_path5.default.join(process.cwd(), response.projectName);
|
|
674
|
+
if (import_node_fs5.default.existsSync(projectDir)) {
|
|
555
675
|
console.error(
|
|
556
676
|
red(`
|
|
557
677
|
Error: Directory "${response.projectName}" already exists.`)
|
|
@@ -561,40 +681,44 @@ Error: Directory "${response.projectName}" already exists.`)
|
|
|
561
681
|
console.log(dim(`
|
|
562
682
|
Building your documentation site...
|
|
563
683
|
`));
|
|
564
|
-
|
|
684
|
+
import_node_fs5.default.mkdirSync(projectDir, { recursive: true });
|
|
565
685
|
console.log(`${green("\u2714")} Created project directory`);
|
|
566
|
-
const configOptions = {
|
|
686
|
+
const configOptions = {};
|
|
567
687
|
if (response.template === "empty") {
|
|
568
688
|
generateEmptyTemplate(projectDir, response.projectName);
|
|
569
689
|
} else if (response.template === "i18n") {
|
|
570
690
|
configOptions.i18n = true;
|
|
691
|
+
configOptions.homePage = "./src/home-page.tsx";
|
|
571
692
|
generateI18nTemplate(projectDir);
|
|
693
|
+
} else if (response.template === "external") {
|
|
694
|
+
generateExternalTemplate(projectDir);
|
|
572
695
|
} else {
|
|
696
|
+
configOptions.homePage = "./src/home-page.tsx";
|
|
573
697
|
generateBaseTemplate(projectDir);
|
|
574
698
|
}
|
|
575
699
|
console.log(`${green("\u2714")} Applied "${response.template}" preset`);
|
|
576
|
-
|
|
577
|
-
|
|
700
|
+
import_node_fs5.default.writeFileSync(
|
|
701
|
+
import_node_path5.default.join(projectDir, "package.json"),
|
|
578
702
|
JSON.stringify(getPackageJson(response.projectName), null, 2)
|
|
579
703
|
);
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
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"),
|
|
584
708
|
markdownlintContent
|
|
585
709
|
);
|
|
586
|
-
|
|
587
|
-
|
|
710
|
+
import_node_fs5.default.writeFileSync(
|
|
711
|
+
import_node_path5.default.join(projectDir, ".markdownlintignore"),
|
|
588
712
|
markdownlintignoreContent
|
|
589
713
|
);
|
|
590
|
-
|
|
591
|
-
|
|
714
|
+
import_node_fs5.default.writeFileSync(
|
|
715
|
+
import_node_path5.default.join(projectDir, "boltdocs.config.ts"),
|
|
592
716
|
getBoltdocsConfig(response.projectName, configOptions)
|
|
593
717
|
);
|
|
594
|
-
const publicDir =
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
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());
|
|
598
722
|
console.log(`${green("\u2714")} Finalized configuration and assets`);
|
|
599
723
|
if (response.install) {
|
|
600
724
|
console.log(cyan(`
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import fs5 from "fs";
|
|
5
|
+
import path5 from "path";
|
|
6
6
|
import { execSync } from "child_process";
|
|
7
7
|
import prompts from "prompts";
|
|
8
8
|
import picocolors from "picocolors";
|
|
@@ -18,6 +18,7 @@ function getPackageJson(projectName) {
|
|
|
18
18
|
dev: "boltdocs",
|
|
19
19
|
build: "boltdocs build",
|
|
20
20
|
preview: "boltdocs preview",
|
|
21
|
+
doctor: "boltdocs doctor",
|
|
21
22
|
"lint:md": 'markdownlint-cli2 "**/*.{md,mdx}"',
|
|
22
23
|
"lint:md:fix": 'markdownlint-cli2 --fix "**/*.{md,mdx}"'
|
|
23
24
|
},
|
|
@@ -88,6 +89,10 @@ function getBoltdocsConfig(projectName, options = {}) {
|
|
|
88
89
|
locales: {
|
|
89
90
|
en: 'English',
|
|
90
91
|
es: 'Espa\xF1ol'
|
|
92
|
+
},
|
|
93
|
+
localeConfigs: {
|
|
94
|
+
en: { label: 'English', direction: 'ltr' },
|
|
95
|
+
es: { label: 'Espa\xF1ol', direction: 'ltr' }
|
|
91
96
|
}
|
|
92
97
|
},` : "";
|
|
93
98
|
const homePageConfig = options.homePage ? `
|
|
@@ -163,14 +168,13 @@ function getLayoutPage() {
|
|
|
163
168
|
Head,
|
|
164
169
|
Breadcrumbs,
|
|
165
170
|
PageNav,
|
|
166
|
-
ProgressBar,
|
|
167
171
|
ErrorBoundary,
|
|
168
172
|
CopyMarkdown,
|
|
169
173
|
useRoutes,
|
|
170
174
|
useConfig,
|
|
171
175
|
useMdxComponents,
|
|
176
|
+
useLocation
|
|
172
177
|
} from 'boltdocs/client'
|
|
173
|
-
import { useLocation} from 'boltdocs/hooks'
|
|
174
178
|
|
|
175
179
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
176
180
|
const { routes: filteredRoutes, allRoutes, currentRoute } = useRoutes()
|
|
@@ -184,7 +188,6 @@ export default function Layout({ children }: { children: React.ReactNode }) {
|
|
|
184
188
|
return (
|
|
185
189
|
<DocsLayout>
|
|
186
190
|
{/* Modern Spotlight Gradients */}
|
|
187
|
-
<ProgressBar />
|
|
188
191
|
<Head
|
|
189
192
|
siteTitle={config.theme?.title || 'Boltdocs'}
|
|
190
193
|
siteDescription={config.theme?.description || ''}
|
|
@@ -294,8 +297,7 @@ export function Button({ children, ...props }: React.ButtonHTMLAttributes<HTMLBu
|
|
|
294
297
|
}
|
|
295
298
|
`;
|
|
296
299
|
fs2.writeFileSync(path2.join(componentsDir, "Button.tsx"), buttonContent);
|
|
297
|
-
const homePageContent = `import { Button } from 'boltdocs/
|
|
298
|
-
import { Cards, Card } from 'boltdocs/mdx'
|
|
300
|
+
const homePageContent = `import { Button, Cards, Card } from 'boltdocs/client';
|
|
299
301
|
|
|
300
302
|
export default function HomePage() {
|
|
301
303
|
return (
|
|
@@ -341,7 +343,7 @@ export default function HomePage() {
|
|
|
341
343
|
`;
|
|
342
344
|
const docsDir = path2.join(projectDir, "docs");
|
|
343
345
|
fs2.mkdirSync(docsDir, { recursive: true });
|
|
344
|
-
fs2.writeFileSync(path2.join(srcDir, "
|
|
346
|
+
fs2.writeFileSync(path2.join(srcDir, "home-page.tsx"), homePageContent);
|
|
345
347
|
fs2.writeFileSync(path2.join(docsDir, "layout.tsx"), getLayoutPage());
|
|
346
348
|
fs2.writeFileSync(path2.join(projectDir, "index.css"), getIndexCss());
|
|
347
349
|
const indexMdx = `---
|
|
@@ -391,11 +393,11 @@ export function Button({ children, className = '', ...props }: React.ButtonHTMLA
|
|
|
391
393
|
fs3.writeFileSync(path3.join(componentsDir, "Button.tsx"), buttonContent);
|
|
392
394
|
const homePageContent = `import React from 'react';
|
|
393
395
|
import { Button } from './components/Button';
|
|
394
|
-
import { useI18n } from 'boltdocs/
|
|
396
|
+
import { useI18n } from 'boltdocs/client';
|
|
395
397
|
|
|
396
398
|
export default function HomePage() {
|
|
397
|
-
const
|
|
398
|
-
const locale =
|
|
399
|
+
const { currentLocale } = useI18n();
|
|
400
|
+
const locale = currentLocale || 'en';
|
|
399
401
|
|
|
400
402
|
const translations: any = {
|
|
401
403
|
en: {
|
|
@@ -429,7 +431,7 @@ export default function HomePage() {
|
|
|
429
431
|
`;
|
|
430
432
|
const docsDir = path3.join(projectDir, "docs");
|
|
431
433
|
fs3.mkdirSync(docsDir, { recursive: true });
|
|
432
|
-
fs3.writeFileSync(path3.join(srcDir, "
|
|
434
|
+
fs3.writeFileSync(path3.join(srcDir, "home-page.tsx"), homePageContent);
|
|
433
435
|
fs3.writeFileSync(path3.join(projectDir, "index.css"), getIndexCss());
|
|
434
436
|
fs3.writeFileSync(path3.join(docsDir, "layout.tsx"), getLayoutPage());
|
|
435
437
|
fs3.writeFileSync(
|
|
@@ -462,6 +464,119 @@ Boltdocs detecta autom\xE1ticamente las carpetas de idiomas.
|
|
|
462
464
|
);
|
|
463
465
|
}
|
|
464
466
|
|
|
467
|
+
// src/templates/external.ts
|
|
468
|
+
import path4 from "path";
|
|
469
|
+
import fs4 from "fs";
|
|
470
|
+
function generateExternalTemplate(projectDir) {
|
|
471
|
+
const srcDir = path4.join(projectDir, "src");
|
|
472
|
+
fs4.mkdirSync(srcDir, { recursive: true });
|
|
473
|
+
const docsDir = path4.join(projectDir, "docs");
|
|
474
|
+
fs4.mkdirSync(docsDir, { recursive: true });
|
|
475
|
+
const externalPagesDir = path4.join(docsDir, "pages-external");
|
|
476
|
+
fs4.mkdirSync(externalPagesDir, { recursive: true });
|
|
477
|
+
const externalPagesContent = `import React from 'react'
|
|
478
|
+
import { PrimitiveButton } from 'boltdocs/client'
|
|
479
|
+
import HomePage from '../../src/home-page'
|
|
480
|
+
|
|
481
|
+
export const homePage = HomePage
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* External pages are standalone React components mapped to specific routes.
|
|
485
|
+
* They are defined outside the standard docs/ hierarchy.
|
|
486
|
+
*/
|
|
487
|
+
export const pages = {
|
|
488
|
+
'/contact': () => (
|
|
489
|
+
<div className="p-20 text-center">
|
|
490
|
+
<h1 className="text-6xl font-black mb-6 bg-linear-to-r from-primary-600 to-primary-400 bg-clip-text text-transparent">
|
|
491
|
+
Contact Us
|
|
492
|
+
</h1>
|
|
493
|
+
<p className="text-xl text-text-muted mb-12 max-w-2xl mx-auto leading-relaxed">
|
|
494
|
+
This is a custom page defined in pages-external/index.tsx.
|
|
495
|
+
It bypassing the standard markdown processing while still being part of your Boltdocs app.
|
|
496
|
+
</p>
|
|
497
|
+
<PrimitiveButton
|
|
498
|
+
onClick={() => window.location.href = '/'}
|
|
499
|
+
className="px-8 py-4 text-lg"
|
|
500
|
+
>
|
|
501
|
+
Return Home
|
|
502
|
+
</PrimitiveButton>
|
|
503
|
+
</div>
|
|
504
|
+
)
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Custom layout specifically for external pages.
|
|
509
|
+
* If not provided, it will fallback to the default app layout.
|
|
510
|
+
*/
|
|
511
|
+
export const layout = ({ children }: { children: React.ReactNode }) => (
|
|
512
|
+
<div className="min-h-screen bg-bg-main text-text-main flex flex-col">
|
|
513
|
+
<header className="p-6 border-b border-border-subtle bg-bg-surface/50 backdrop-blur-md sticky top-0 z-50">
|
|
514
|
+
<div className="max-w-7xl mx-auto flex justify-between items-center">
|
|
515
|
+
<div className="font-black text-2xl tracking-tight">BOLTDOCS <span className="text-primary-500 text-sm font-medium">EXTERNAL</span></div>
|
|
516
|
+
<nav className="flex gap-6 items-center">
|
|
517
|
+
<a href="/" className="text-sm font-medium hover:text-primary-500 transition-colors">Home</a>
|
|
518
|
+
<a href="/docs" className="text-sm font-medium hover:text-primary-500 transition-colors">Documentation</a>
|
|
519
|
+
</nav>
|
|
520
|
+
</div>
|
|
521
|
+
</header>
|
|
522
|
+
<main className="flex-1">
|
|
523
|
+
{children}
|
|
524
|
+
</main>
|
|
525
|
+
<footer className="p-12 border-t border-border-subtle bg-bg-muted/30">
|
|
526
|
+
<div className="max-w-7xl mx-auto text-center">
|
|
527
|
+
<p className="text-sm text-text-muted font-medium italic">
|
|
528
|
+
"The best way to predict the future is to documenting it."
|
|
529
|
+
</p>
|
|
530
|
+
</div>
|
|
531
|
+
</footer>
|
|
532
|
+
</div>
|
|
533
|
+
)
|
|
534
|
+
`;
|
|
535
|
+
fs4.writeFileSync(
|
|
536
|
+
path4.join(externalPagesDir, "index.tsx"),
|
|
537
|
+
externalPagesContent
|
|
538
|
+
);
|
|
539
|
+
const homePageContent = `import React from 'react'
|
|
540
|
+
import { Button } from 'boltdocs/client'
|
|
541
|
+
|
|
542
|
+
export default function HomePage() {
|
|
543
|
+
return (
|
|
544
|
+
<div className="hero-section">
|
|
545
|
+
<h1 className="hero-title text-center">External Pages</h1>
|
|
546
|
+
<p className="hero-subtitle text-center">
|
|
547
|
+
Boltdocs now supports standalone React pages and custom layouts outside the standard docs structure.
|
|
548
|
+
</p>
|
|
549
|
+
<div className="flex gap-4">
|
|
550
|
+
<a href="/docs" className="no-underline">
|
|
551
|
+
<Button className="text-lg px-10 py-4">Read Docs</Button>
|
|
552
|
+
</a>
|
|
553
|
+
<a href="/contact" className="no-underline">
|
|
554
|
+
<Button variant="ghost" className="text-lg px-10 py-4">External Page</Button>
|
|
555
|
+
</a>
|
|
556
|
+
</div>
|
|
557
|
+
</div>
|
|
558
|
+
)
|
|
559
|
+
}
|
|
560
|
+
`;
|
|
561
|
+
fs4.writeFileSync(path4.join(srcDir, "home-page.tsx"), homePageContent);
|
|
562
|
+
fs4.writeFileSync(path4.join(projectDir, "index.css"), getIndexCss());
|
|
563
|
+
fs4.writeFileSync(
|
|
564
|
+
path4.join(docsDir, "index.mdx"),
|
|
565
|
+
`---
|
|
566
|
+
title: Introduction
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
# External Pages Feature
|
|
570
|
+
|
|
571
|
+
This project demonstrates the \`pages-external\` feature of Boltdocs.
|
|
572
|
+
|
|
573
|
+
Check out [Contact Page](/contact) to see it in action.
|
|
574
|
+
|
|
575
|
+
The source code for that page is located in \`docs/pages-external/index.tsx\`.
|
|
576
|
+
`
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
|
|
465
580
|
// src/index.ts
|
|
466
581
|
var { green, yellow, bold, cyan, magenta, blue, red, dim } = picocolors;
|
|
467
582
|
function getPackageManager() {
|
|
@@ -484,7 +599,7 @@ async function run() {
|
|
|
484
599
|
)
|
|
485
600
|
);
|
|
486
601
|
console.log(dim(`
|
|
487
|
-
v0.0.
|
|
602
|
+
v0.0.2 - The modern documentation framework
|
|
488
603
|
`));
|
|
489
604
|
const response = await prompts([
|
|
490
605
|
{
|
|
@@ -512,6 +627,11 @@ async function run() {
|
|
|
512
627
|
title: yellow("i18n"),
|
|
513
628
|
description: "Multi-language support (EN/ES).",
|
|
514
629
|
value: "i18n"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
title: blue("External"),
|
|
633
|
+
description: "Custom routes and external layouts.",
|
|
634
|
+
value: "external"
|
|
515
635
|
}
|
|
516
636
|
],
|
|
517
637
|
initial: 1
|
|
@@ -527,8 +647,8 @@ async function run() {
|
|
|
527
647
|
console.log(yellow("\nOperation canceled."));
|
|
528
648
|
return;
|
|
529
649
|
}
|
|
530
|
-
const projectDir =
|
|
531
|
-
if (
|
|
650
|
+
const projectDir = path5.join(process.cwd(), response.projectName);
|
|
651
|
+
if (fs5.existsSync(projectDir)) {
|
|
532
652
|
console.error(
|
|
533
653
|
red(`
|
|
534
654
|
Error: Directory "${response.projectName}" already exists.`)
|
|
@@ -538,40 +658,44 @@ Error: Directory "${response.projectName}" already exists.`)
|
|
|
538
658
|
console.log(dim(`
|
|
539
659
|
Building your documentation site...
|
|
540
660
|
`));
|
|
541
|
-
|
|
661
|
+
fs5.mkdirSync(projectDir, { recursive: true });
|
|
542
662
|
console.log(`${green("\u2714")} Created project directory`);
|
|
543
|
-
const configOptions = {
|
|
663
|
+
const configOptions = {};
|
|
544
664
|
if (response.template === "empty") {
|
|
545
665
|
generateEmptyTemplate(projectDir, response.projectName);
|
|
546
666
|
} else if (response.template === "i18n") {
|
|
547
667
|
configOptions.i18n = true;
|
|
668
|
+
configOptions.homePage = "./src/home-page.tsx";
|
|
548
669
|
generateI18nTemplate(projectDir);
|
|
670
|
+
} else if (response.template === "external") {
|
|
671
|
+
generateExternalTemplate(projectDir);
|
|
549
672
|
} else {
|
|
673
|
+
configOptions.homePage = "./src/home-page.tsx";
|
|
550
674
|
generateBaseTemplate(projectDir);
|
|
551
675
|
}
|
|
552
676
|
console.log(`${green("\u2714")} Applied "${response.template}" preset`);
|
|
553
|
-
|
|
554
|
-
|
|
677
|
+
fs5.writeFileSync(
|
|
678
|
+
path5.join(projectDir, "package.json"),
|
|
555
679
|
JSON.stringify(getPackageJson(response.projectName), null, 2)
|
|
556
680
|
);
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
681
|
+
fs5.writeFileSync(path5.join(projectDir, ".gitignore"), gitignoreContent);
|
|
682
|
+
fs5.writeFileSync(path5.join(projectDir, ".npmignore"), gitignoreContent);
|
|
683
|
+
fs5.writeFileSync(
|
|
684
|
+
path5.join(projectDir, ".markdownlint.yaml"),
|
|
561
685
|
markdownlintContent
|
|
562
686
|
);
|
|
563
|
-
|
|
564
|
-
|
|
687
|
+
fs5.writeFileSync(
|
|
688
|
+
path5.join(projectDir, ".markdownlintignore"),
|
|
565
689
|
markdownlintignoreContent
|
|
566
690
|
);
|
|
567
|
-
|
|
568
|
-
|
|
691
|
+
fs5.writeFileSync(
|
|
692
|
+
path5.join(projectDir, "boltdocs.config.ts"),
|
|
569
693
|
getBoltdocsConfig(response.projectName, configOptions)
|
|
570
694
|
);
|
|
571
|
-
const publicDir =
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
695
|
+
const publicDir = path5.join(projectDir, "public");
|
|
696
|
+
fs5.mkdirSync(publicDir, { recursive: true });
|
|
697
|
+
fs5.writeFileSync(path5.join(publicDir, "logo-light.svg"), getLogoLight());
|
|
698
|
+
fs5.writeFileSync(path5.join(publicDir, "logo-dark.svg"), getLogoDark());
|
|
575
699
|
console.log(`${green("\u2714")} Finalized configuration and assets`);
|
|
576
700
|
if (response.install) {
|
|
577
701
|
console.log(cyan(`
|