boltdocs 1.11.0 → 2.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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/bin/boltdocs.js +12 -0
- package/dist/cache-Q4T6VAUL.mjs +1 -0
- package/dist/chunk-52MVMZWS.mjs +1 -0
- package/dist/chunk-BVWWKXJH.mjs +1 -0
- package/dist/chunk-DVY3RDXD.mjs +1 -0
- package/dist/chunk-FUVYCYWC.mjs +1 -0
- package/dist/chunk-GBLMDJ2B.mjs +1 -0
- package/dist/chunk-ISPX45DF.mjs +1 -0
- package/dist/chunk-PNXZMUCO.mjs +1 -0
- package/dist/chunk-V2ZHKQSP.mjs +74 -0
- package/dist/client/components/mdx/index.d.mts +208 -0
- package/dist/client/components/mdx/index.d.ts +208 -0
- package/dist/client/components/mdx/index.js +1 -0
- package/dist/client/components/mdx/index.mjs +1 -0
- package/dist/client/hooks/index.d.mts +132 -0
- package/dist/client/hooks/index.d.ts +132 -0
- package/dist/client/hooks/index.js +1 -0
- package/dist/client/hooks/index.mjs +1 -0
- package/dist/client/index.d.mts +210 -0
- package/dist/client/index.d.ts +210 -0
- package/dist/client/index.js +1 -0
- package/dist/client/index.mjs +1 -0
- package/dist/client/ssr.d.mts +78 -0
- package/dist/client/ssr.d.ts +78 -0
- package/dist/client/ssr.js +1 -0
- package/dist/client/ssr.mjs +1 -0
- package/dist/node/cli-entry.d.mts +1 -0
- package/dist/node/cli-entry.d.ts +1 -0
- package/dist/node/cli-entry.js +75 -0
- package/dist/node/cli-entry.mjs +2 -0
- package/dist/node/index.d.mts +298 -0
- package/dist/node/index.d.ts +298 -0
- package/dist/node/index.js +74 -0
- package/dist/node/index.mjs +1 -0
- package/dist/search-dialog-TWGYKF2D.mjs +1 -0
- package/dist/types-Cp21DHI6.d.mts +355 -0
- package/dist/types-Cp21DHI6.d.ts +355 -0
- package/dist/use-routes-8Iei6jTp.d.mts +29 -0
- package/dist/use-routes-xLhumjbV.d.ts +29 -0
- package/package.json +16 -10
- package/src/client/app/index.tsx +9 -6
- package/src/client/components/ui-base/breadcrumbs.tsx +2 -1
- package/src/client/components/ui-base/navbar.tsx +3 -3
- package/src/client/components/ui-base/sidebar.tsx +2 -1
- package/src/client/hooks/use-navbar.ts +1 -1
- package/src/client/types.ts +1 -1
- package/src/node/cli-entry.ts +24 -0
- package/src/node/cli.ts +59 -0
- package/src/node/config.ts +63 -11
- package/src/node/index.ts +39 -3
- package/src/node/plugin/entry.ts +7 -0
- package/src/node/plugin/html.ts +49 -9
- package/src/node/plugin/index.ts +42 -4
- package/src/node/routes/parser.ts +27 -32
- package/src/node/ssg/index.ts +35 -4
- package/src/node/ssg/robots.ts +50 -0
- package/src/node/utils.ts +23 -0
- package/tsup.config.ts +36 -10
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import * as vite from 'vite';
|
|
3
|
+
import { Plugin } from 'vite';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a single social link in the configuration.
|
|
7
|
+
*/
|
|
8
|
+
interface BoltdocsSocialLink {
|
|
9
|
+
/** Identifier for the icon (e.g., 'github') */
|
|
10
|
+
icon: 'discord' | 'x' | 'github' | 'bluesky' | string;
|
|
11
|
+
/** The URL the social link points to */
|
|
12
|
+
link: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configuration for the site footer.
|
|
16
|
+
*/
|
|
17
|
+
interface BoltdocsFooterConfig {
|
|
18
|
+
/** Text to display in the footer (HTML is supported) */
|
|
19
|
+
text?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Theme-specific configuration options governing the appearance and navigation of the site.
|
|
23
|
+
*/
|
|
24
|
+
interface BoltdocsThemeConfig {
|
|
25
|
+
/** The global title of the documentation site */
|
|
26
|
+
title?: string;
|
|
27
|
+
/** The global description of the site (used for SEO) */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** URL path to the site logo or an object for light/dark versions */
|
|
30
|
+
logo?: string | {
|
|
31
|
+
dark: string;
|
|
32
|
+
light: string;
|
|
33
|
+
alt?: string;
|
|
34
|
+
width?: number;
|
|
35
|
+
height?: number;
|
|
36
|
+
};
|
|
37
|
+
/** Items to display in the top navigation bar */
|
|
38
|
+
navbar?: Array<{
|
|
39
|
+
/** Text to display */
|
|
40
|
+
label: string;
|
|
41
|
+
/** URL path or external link */
|
|
42
|
+
href: string;
|
|
43
|
+
/** Nested items for NavigationMenu */
|
|
44
|
+
items?: Array<{
|
|
45
|
+
label: string;
|
|
46
|
+
href: string;
|
|
47
|
+
}>;
|
|
48
|
+
}>;
|
|
49
|
+
/** Items to display in the sidebar, organized optionally by group URLs */
|
|
50
|
+
sidebar?: Record<string, Array<{
|
|
51
|
+
text: string;
|
|
52
|
+
link: string;
|
|
53
|
+
}>>;
|
|
54
|
+
/** Social links to display in the navigation bar */
|
|
55
|
+
socialLinks?: BoltdocsSocialLink[];
|
|
56
|
+
/** Site footer configuration */
|
|
57
|
+
footer?: BoltdocsFooterConfig;
|
|
58
|
+
/** Whether to show breadcrumbs navigation (default: true) */
|
|
59
|
+
breadcrumbs?: boolean;
|
|
60
|
+
/** URL template for 'Edit this page'. Use :path as a placeholder. */
|
|
61
|
+
editLink?: string;
|
|
62
|
+
/** URL for the 'Community help' link. */
|
|
63
|
+
communityHelp?: string;
|
|
64
|
+
/** The current version of the project (e.g., 'v2.8.9'). Displayed in the Navbar. */
|
|
65
|
+
version?: string;
|
|
66
|
+
/** The GitHub repository in the format 'owner/repo' to fetch and display star count. */
|
|
67
|
+
githubRepo?: string;
|
|
68
|
+
/**
|
|
69
|
+
* URL path to the site favicon.
|
|
70
|
+
* If not specified, the logo will be used if available.
|
|
71
|
+
*/
|
|
72
|
+
favicon?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The Open Graph image URL to display when the site is shared on social media.
|
|
75
|
+
*/
|
|
76
|
+
ogImage?: string;
|
|
77
|
+
/** Whether to show the 'Powered by LiteDocs' badge in the sidebar (default: true) */
|
|
78
|
+
poweredBy?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Top-level tabs for organizing documentation groups.
|
|
81
|
+
* Tab discovery uses the (tab-id) directory syntax.
|
|
82
|
+
*/
|
|
83
|
+
tabs?: Array<{
|
|
84
|
+
id: string;
|
|
85
|
+
text: string;
|
|
86
|
+
icon?: string;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* The syntax highlighting theme for code blocks.
|
|
90
|
+
* Supports any Shiki theme name (e.g., 'github-dark', 'one-dark-pro', 'aurora-x').
|
|
91
|
+
* Can also be an object for multiple themes (e.g., { light: 'github-light', dark: 'github-dark' }).
|
|
92
|
+
* Default: { light: 'github-light', dark: 'one-dark-pro' }
|
|
93
|
+
*/
|
|
94
|
+
codeTheme?: string | {
|
|
95
|
+
light: string;
|
|
96
|
+
dark: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Configuration for the 'Copy Markdown' button.
|
|
100
|
+
* Can be a boolean or an object with text and icon.
|
|
101
|
+
* Default: true
|
|
102
|
+
*/
|
|
103
|
+
copyMarkdown?: boolean | {
|
|
104
|
+
text?: string;
|
|
105
|
+
icon?: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Configuration for the robots.txt file.
|
|
110
|
+
*/
|
|
111
|
+
type BoltdocsRobotsConfig = string | {
|
|
112
|
+
/** User-agent rules */
|
|
113
|
+
rules?: Array<{
|
|
114
|
+
userAgent: string;
|
|
115
|
+
/** Paths allowed to be crawled */
|
|
116
|
+
allow?: string | string[];
|
|
117
|
+
/** Paths disallowed to be crawled */
|
|
118
|
+
disallow?: string | string[];
|
|
119
|
+
}>;
|
|
120
|
+
/** Sitemaps to include in the robots.txt */
|
|
121
|
+
sitemaps?: string[];
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Configuration for internationalization (i18n).
|
|
125
|
+
*/
|
|
126
|
+
interface BoltdocsI18nConfig {
|
|
127
|
+
/** The default locale (e.g., 'en') */
|
|
128
|
+
defaultLocale: string;
|
|
129
|
+
/** Available locales and their display names (e.g., { en: 'English', es: 'Español' }) */
|
|
130
|
+
locales: Record<string, string>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Configuration for documentation versioning.
|
|
134
|
+
*/
|
|
135
|
+
interface BoltdocsVersionsConfig {
|
|
136
|
+
/** The default version (e.g., 'v2') */
|
|
137
|
+
defaultVersion: string;
|
|
138
|
+
/** Available versions and their display names (e.g., { v1: 'Version 1.x', v2: 'Version 2.x' }) */
|
|
139
|
+
versions: Record<string, string>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Defines a Boltdocs plugin that can extend the build process and client-side functionality.
|
|
143
|
+
*/
|
|
144
|
+
interface BoltdocsPlugin {
|
|
145
|
+
/** A unique name for the plugin */
|
|
146
|
+
name: string;
|
|
147
|
+
/** Whether to run this plugin before or after default ones (optional) */
|
|
148
|
+
enforce?: 'pre' | 'post';
|
|
149
|
+
/** Optional remark plugins to add to the MDX pipeline */
|
|
150
|
+
remarkPlugins?: unknown[];
|
|
151
|
+
/** Optional rehype plugins to add to the MDX pipeline */
|
|
152
|
+
rehypePlugins?: unknown[];
|
|
153
|
+
/** Optional Vite plugins to inject into the build process */
|
|
154
|
+
vitePlugins?: Plugin[];
|
|
155
|
+
/** Optional custom React components to register in MDX. Map of Name -> Module Path. */
|
|
156
|
+
components?: Record<string, string>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Configuration for external integrations (e.g., CodeSandbox).
|
|
160
|
+
*/
|
|
161
|
+
interface BoltdocsIntegrationsConfig {
|
|
162
|
+
/** CodeSandbox integration settings */
|
|
163
|
+
sandbox?: {
|
|
164
|
+
/** Whether to enable the "Open in Sandbox" button in CodeBlocks */
|
|
165
|
+
enable?: boolean;
|
|
166
|
+
/** Default options for the sandbox (files, dependencies, etc.) */
|
|
167
|
+
config?: Record<string, unknown>;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The root configuration object for Boltdocs.
|
|
172
|
+
*/
|
|
173
|
+
interface BoltdocsConfig {
|
|
174
|
+
/** The base URL of the site, used for generating the sitemap */
|
|
175
|
+
siteUrl?: string;
|
|
176
|
+
/** The root directory containing markdown documentation files (default: 'docs') */
|
|
177
|
+
docsDir?: string;
|
|
178
|
+
/** Path to a custom HomePage component */
|
|
179
|
+
homePage?: string;
|
|
180
|
+
/** Configuration pertaining to the UI and appearance */
|
|
181
|
+
theme?: BoltdocsThemeConfig;
|
|
182
|
+
/** Configuration for internationalization */
|
|
183
|
+
i18n?: BoltdocsI18nConfig;
|
|
184
|
+
/** Configuration for documentation versioning */
|
|
185
|
+
versions?: BoltdocsVersionsConfig;
|
|
186
|
+
/** Custom plugins for extending functionality */
|
|
187
|
+
plugins?: BoltdocsPlugin[];
|
|
188
|
+
/** Map of custom external route paths to component file paths */
|
|
189
|
+
external?: Record<string, string>;
|
|
190
|
+
/** External integrations configuration */
|
|
191
|
+
integrations?: BoltdocsIntegrationsConfig;
|
|
192
|
+
/** Configuration for the robots.txt file */
|
|
193
|
+
robots?: BoltdocsRobotsConfig;
|
|
194
|
+
/** Low-level Vite configuration overrides */
|
|
195
|
+
vite?: vite.InlineConfig;
|
|
196
|
+
/** @deprecated Use theme instead */
|
|
197
|
+
themeConfig?: BoltdocsThemeConfig;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Metadata provided by the server for a specific route.
|
|
202
|
+
* Maps closely to the `RouteMeta` type in the Node environment.
|
|
203
|
+
*/
|
|
204
|
+
interface ComponentRoute {
|
|
205
|
+
/** The final URL path */
|
|
206
|
+
path: string;
|
|
207
|
+
/** The absolute filesystem path of the source file */
|
|
208
|
+
componentPath: string;
|
|
209
|
+
/** The page title */
|
|
210
|
+
title: string;
|
|
211
|
+
/** Explicit order in the sidebar */
|
|
212
|
+
sidebarPosition?: number;
|
|
213
|
+
/** The relative path from the docs directory */
|
|
214
|
+
filePath: string;
|
|
215
|
+
/** The group directory name */
|
|
216
|
+
group?: string;
|
|
217
|
+
/** The display title of the group */
|
|
218
|
+
groupTitle?: string;
|
|
219
|
+
/** Explicit order of the group in the sidebar */
|
|
220
|
+
groupPosition?: number;
|
|
221
|
+
/** Extracted markdown headings for search indexing */
|
|
222
|
+
headings?: {
|
|
223
|
+
level: number;
|
|
224
|
+
text: string;
|
|
225
|
+
id: string;
|
|
226
|
+
}[];
|
|
227
|
+
/** The page summary or description */
|
|
228
|
+
description?: string;
|
|
229
|
+
/** The locale this route belongs to, if i18n is configured */
|
|
230
|
+
locale?: string;
|
|
231
|
+
/** The version this route belongs to, if versioning is configured */
|
|
232
|
+
version?: string;
|
|
233
|
+
/** Optional icon to display (Lucide icon name or raw SVG) */
|
|
234
|
+
icon?: string;
|
|
235
|
+
/** The tab this route belongs to, if tabs are configured */
|
|
236
|
+
tab?: string;
|
|
237
|
+
/** Optional badge to display next to the sidebar item */
|
|
238
|
+
badge?: string | {
|
|
239
|
+
text: 'updated' | 'new' | 'deprecated';
|
|
240
|
+
expires?: string;
|
|
241
|
+
};
|
|
242
|
+
/** Optional icon for the route's group */
|
|
243
|
+
groupIcon?: string;
|
|
244
|
+
/** The extracted plain-text content of the page for search indexing */
|
|
245
|
+
_content?: string;
|
|
246
|
+
/** The raw markdown content of the page */
|
|
247
|
+
_rawContent?: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Site configuration provided by the server.
|
|
251
|
+
*/
|
|
252
|
+
type SiteConfig = BoltdocsConfig;
|
|
253
|
+
/**
|
|
254
|
+
* Configuration options for initializing the Boltdocs client app.
|
|
255
|
+
*/
|
|
256
|
+
interface CreateBoltdocsAppOptions {
|
|
257
|
+
/** CSS selector for the DOM element where the app should mount (e.g. '#root') */
|
|
258
|
+
target: string;
|
|
259
|
+
/** Initial routes generated by the Vite plugin (`virtual:boltdocs-routes`) */
|
|
260
|
+
routes: ComponentRoute[];
|
|
261
|
+
/** The name of the documentation directory (e.g. 'docs') */
|
|
262
|
+
docsDirName: string;
|
|
263
|
+
/** Site configuration (`virtual:boltdocs-config`) */
|
|
264
|
+
config: SiteConfig;
|
|
265
|
+
/** Dynamic import mapping from `import.meta.glob` for the documentation pages */
|
|
266
|
+
modules: Record<string, () => Promise<{
|
|
267
|
+
default: React__default.ComponentType<any>;
|
|
268
|
+
}>>;
|
|
269
|
+
/** The `import.meta.hot` instance necessary for fast refresh/HMR updates */
|
|
270
|
+
hot?: {
|
|
271
|
+
accept: (cb?: (mod: any) => void) => void;
|
|
272
|
+
dispose: (cb: (data: any) => void) => void;
|
|
273
|
+
on: (event: string, cb: (data: any) => void) => void;
|
|
274
|
+
data: any;
|
|
275
|
+
};
|
|
276
|
+
/** Optional custom React component to render when visiting the root path ('/') */
|
|
277
|
+
homePage?: React__default.ComponentType;
|
|
278
|
+
/** Custom external pages mapped by their route path */
|
|
279
|
+
externalPages?: Record<string, React__default.ComponentType>;
|
|
280
|
+
/** Optional custom MDX components provided by plugins */
|
|
281
|
+
components?: Record<string, React__default.ComponentType>;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Types for CodeSandbox integration.
|
|
285
|
+
*/
|
|
286
|
+
interface SandboxFile {
|
|
287
|
+
content: string | object;
|
|
288
|
+
isBinary?: boolean;
|
|
289
|
+
}
|
|
290
|
+
type SandboxFiles = Record<string, SandboxFile>;
|
|
291
|
+
interface SandboxOptions {
|
|
292
|
+
files?: SandboxFiles;
|
|
293
|
+
dependencies?: Record<string, string>;
|
|
294
|
+
devDependencies?: Record<string, string>;
|
|
295
|
+
title?: string;
|
|
296
|
+
description?: string;
|
|
297
|
+
template?: string;
|
|
298
|
+
/** The file path to open by default in the editor (e.g. `"src/App.tsx"`). */
|
|
299
|
+
entry?: string;
|
|
300
|
+
/** Options for the embedded iframe view, used by `embedSandbox()`. */
|
|
301
|
+
embed?: SandboxEmbedOptions;
|
|
302
|
+
/** Custom scripts for the package.json (e.g. `{ "start": "vite" }`). */
|
|
303
|
+
scripts?: Record<string, string>;
|
|
304
|
+
/** Optional default theme configuration for the sandbox project. */
|
|
305
|
+
themeConfig?: Record<string, unknown>;
|
|
306
|
+
}
|
|
307
|
+
interface SandboxEmbedOptions {
|
|
308
|
+
/** Which panel to display: `"editor"`, `"preview"`, or `"split"`. */
|
|
309
|
+
view?: 'editor' | 'preview' | 'split';
|
|
310
|
+
/** Color theme: `"dark"` or `"light"`. */
|
|
311
|
+
theme?: 'dark' | 'light';
|
|
312
|
+
/** Whether to hide the navigation bar in the embed. */
|
|
313
|
+
hideNavigation?: boolean;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Tab configuration for the documentation site.
|
|
317
|
+
*/
|
|
318
|
+
interface BoltdocsTab {
|
|
319
|
+
id: string;
|
|
320
|
+
text: string;
|
|
321
|
+
icon?: string;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Props for the OnThisPage (TOC) component.
|
|
325
|
+
*/
|
|
326
|
+
interface OnThisPageProps {
|
|
327
|
+
headings?: {
|
|
328
|
+
level: number;
|
|
329
|
+
text: string;
|
|
330
|
+
id: string;
|
|
331
|
+
}[];
|
|
332
|
+
editLink?: string;
|
|
333
|
+
communityHelp?: string;
|
|
334
|
+
filePath?: string;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Props for user-defined layout components (layout.tsx).
|
|
338
|
+
*/
|
|
339
|
+
interface LayoutProps {
|
|
340
|
+
children: React__default.ReactNode;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Unified type for navbar links.
|
|
344
|
+
*/
|
|
345
|
+
interface NavbarLink {
|
|
346
|
+
label: string;
|
|
347
|
+
href: string;
|
|
348
|
+
active: boolean;
|
|
349
|
+
/** Optional icon or string for external link indication */
|
|
350
|
+
to?: string;
|
|
351
|
+
/** Nested items for NavigationMenu */
|
|
352
|
+
items?: NavbarLink[];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export type { BoltdocsConfig as B, ComponentRoute as C, LayoutProps as L, NavbarLink as N, OnThisPageProps as O, SandboxOptions as S, BoltdocsSocialLink as a, BoltdocsTab as b, CreateBoltdocsAppOptions as c, BoltdocsThemeConfig as d, SandboxEmbedOptions as e, SandboxFile as f, SandboxFiles as g };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as ComponentRoute, B as BoltdocsConfig } from './types-Cp21DHI6.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook to access the framework's routing state.
|
|
5
|
+
* Returns both the complete set of routes and a filtered list based on the current
|
|
6
|
+
* version and locale.
|
|
7
|
+
*/
|
|
8
|
+
declare function useRoutes(): {
|
|
9
|
+
routes: ComponentRoute[];
|
|
10
|
+
allRoutes: ComponentRoute[];
|
|
11
|
+
currentRoute: ComponentRoute | undefined;
|
|
12
|
+
currentLocale: string | undefined;
|
|
13
|
+
currentLocaleLabel: string | undefined;
|
|
14
|
+
availableLocales: {
|
|
15
|
+
key: string;
|
|
16
|
+
label: string;
|
|
17
|
+
isCurrent: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
currentVersion: string | undefined;
|
|
20
|
+
currentVersionLabel: string | undefined;
|
|
21
|
+
availableVersions: {
|
|
22
|
+
key: string;
|
|
23
|
+
label: string;
|
|
24
|
+
isCurrent: boolean;
|
|
25
|
+
}[];
|
|
26
|
+
config: BoltdocsConfig;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { useRoutes as u };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as ComponentRoute, B as BoltdocsConfig } from './types-Cp21DHI6.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook to access the framework's routing state.
|
|
5
|
+
* Returns both the complete set of routes and a filtered list based on the current
|
|
6
|
+
* version and locale.
|
|
7
|
+
*/
|
|
8
|
+
declare function useRoutes(): {
|
|
9
|
+
routes: ComponentRoute[];
|
|
10
|
+
allRoutes: ComponentRoute[];
|
|
11
|
+
currentRoute: ComponentRoute | undefined;
|
|
12
|
+
currentLocale: string | undefined;
|
|
13
|
+
currentLocaleLabel: string | undefined;
|
|
14
|
+
availableLocales: {
|
|
15
|
+
key: string;
|
|
16
|
+
label: string;
|
|
17
|
+
isCurrent: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
currentVersion: string | undefined;
|
|
20
|
+
currentVersionLabel: string | undefined;
|
|
21
|
+
availableVersions: {
|
|
22
|
+
key: string;
|
|
23
|
+
label: string;
|
|
24
|
+
isCurrent: boolean;
|
|
25
|
+
}[];
|
|
26
|
+
config: BoltdocsConfig;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { useRoutes as u };
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boltdocs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A lightweight documentation generator for React projects.",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
6
|
"module": "dist/node/index.mjs",
|
|
7
7
|
"types": "dist/node/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"boltdocs": "bin/boltdocs.js"
|
|
10
|
+
},
|
|
8
11
|
"publishConfig": {
|
|
9
12
|
"access": "public"
|
|
10
13
|
},
|
|
@@ -36,13 +39,6 @@
|
|
|
36
39
|
},
|
|
37
40
|
"./theme/neutral.css": "./src/client/theme/neutral.css"
|
|
38
41
|
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsup",
|
|
41
|
-
"dev": "tsup --watch",
|
|
42
|
-
"format": "pnpm exec biome format --write",
|
|
43
|
-
"lint": "pnpm exec biome lint --write",
|
|
44
|
-
"check": "pnpm exec biome check --write"
|
|
45
|
-
},
|
|
46
42
|
"keywords": [
|
|
47
43
|
"docs",
|
|
48
44
|
"documentation",
|
|
@@ -60,12 +56,16 @@
|
|
|
60
56
|
"dependencies": {
|
|
61
57
|
"@mdx-js/react": "^3.1.1",
|
|
62
58
|
"@mdx-js/rollup": "^3.1.1",
|
|
59
|
+
"@tailwindcss/vite": "^4.2.2",
|
|
60
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
61
|
+
"cac": "^7.0.0",
|
|
63
62
|
"class-variance-authority": "^0.7.1",
|
|
64
63
|
"clsx": "^2.1.1",
|
|
65
64
|
"codesandbox": "^2.2.3",
|
|
66
65
|
"fast-glob": "^3.3.3",
|
|
67
66
|
"github-slugger": "^2.0.0",
|
|
68
67
|
"gray-matter": "^4.0.3",
|
|
68
|
+
"isomorphic-dompurify": "^3.7.1",
|
|
69
69
|
"lucide-react": "^0.575.0",
|
|
70
70
|
"react-aria-components": "^1.16.0",
|
|
71
71
|
"react-router-dom": "^6.30.3",
|
|
@@ -85,7 +85,6 @@
|
|
|
85
85
|
"react": "^19.1.0",
|
|
86
86
|
"react-dom": "^19.1.0"
|
|
87
87
|
},
|
|
88
|
-
"packageManager": "pnpm@10.30.2",
|
|
89
88
|
"devDependencies": {
|
|
90
89
|
"@types/node": "^25.3.2",
|
|
91
90
|
"@types/react": "^19.2.14",
|
|
@@ -93,5 +92,12 @@
|
|
|
93
92
|
"@types/react-router-dom": "^5.3.3",
|
|
94
93
|
"tsup": "^8.5.1",
|
|
95
94
|
"typescript": "^5.9.3"
|
|
95
|
+
},
|
|
96
|
+
"scripts": {
|
|
97
|
+
"build": "tsup",
|
|
98
|
+
"dev": "tsup --watch",
|
|
99
|
+
"format": "pnpm exec biome format --write",
|
|
100
|
+
"lint": "pnpm exec biome lint --write",
|
|
101
|
+
"check": "pnpm exec biome check --write"
|
|
96
102
|
}
|
|
97
|
-
}
|
|
103
|
+
}
|
package/src/client/app/index.tsx
CHANGED
|
@@ -31,7 +31,7 @@ export function AppShell({
|
|
|
31
31
|
initialRoutes: ComponentRoute[]
|
|
32
32
|
initialConfig: BoltdocsConfig
|
|
33
33
|
docsDirName: string
|
|
34
|
-
modules: Record<string, () => Promise<{ default: React.ComponentType }>>
|
|
34
|
+
modules: Record<string, () => Promise<{ default: React.ComponentType<any> }>>
|
|
35
35
|
hot?: CreateBoltdocsAppOptions['hot']
|
|
36
36
|
homePage?: React.ComponentType
|
|
37
37
|
externalPages?: Record<string, React.ComponentType>
|
|
@@ -50,15 +50,19 @@ export function AppShell({
|
|
|
50
50
|
)
|
|
51
51
|
.map((route) => {
|
|
52
52
|
const loaderKey = Object.keys(modules).find(
|
|
53
|
-
(k) =>
|
|
53
|
+
(k) =>
|
|
54
|
+
k === `/${docsDirName}/${route.filePath}` || // Vite dev/build relative path
|
|
55
|
+
k.endsWith(`/${docsDirName}/${route.filePath}`) || // SSG absolute path fallback
|
|
56
|
+
k.endsWith(`/${docsDirName}\\${route.filePath.replace(/\\/g, '/')}`), // Windows fallback
|
|
54
57
|
)
|
|
55
58
|
const loader = loaderKey ? modules[loaderKey] : null
|
|
56
59
|
|
|
57
60
|
return {
|
|
58
61
|
...route,
|
|
59
|
-
Component: React.lazy(() => {
|
|
60
|
-
if (!loader) return
|
|
61
|
-
|
|
62
|
+
Component: React.lazy<React.ComponentType<any>>(async () => {
|
|
63
|
+
if (!loader) return { default: NotFound as React.ComponentType<any> }
|
|
64
|
+
const mod = await loader()
|
|
65
|
+
return mod
|
|
62
66
|
}),
|
|
63
67
|
}
|
|
64
68
|
})
|
|
@@ -113,7 +117,6 @@ export function AppShell({
|
|
|
113
117
|
),
|
|
114
118
|
)}
|
|
115
119
|
|
|
116
|
-
{/* Documentation pages WITH sidebar + TOC layout */}
|
|
117
120
|
<Route key="docs-layout" element={<DocsLayout />}>
|
|
118
121
|
{resolvedRoutes.map((route) => (
|
|
119
122
|
<Route
|
|
@@ -12,10 +12,11 @@ import { useConfig } from '@client/app/config-context'
|
|
|
12
12
|
export function Breadcrumbs() {
|
|
13
13
|
const { crumbs, activeRoute } = useBreadcrumbs()
|
|
14
14
|
const config = useConfig()
|
|
15
|
+
const themeConfig = config.theme || config.themeConfig || {}
|
|
15
16
|
|
|
16
17
|
if (crumbs.length === 0) return null
|
|
17
18
|
|
|
18
|
-
if (!
|
|
19
|
+
if (!themeConfig?.breadcrumbs) return null
|
|
19
20
|
|
|
20
21
|
return (
|
|
21
22
|
<BreadcrumbsRoot>
|
|
@@ -24,7 +24,7 @@ export function Navbar() {
|
|
|
24
24
|
const { links, title, logo, logoProps, github, social, config } = useNavbar()
|
|
25
25
|
const { routes, allRoutes, currentVersion, currentLocale } = useRoutes()
|
|
26
26
|
const { pathname } = useLocation()
|
|
27
|
-
const
|
|
27
|
+
const themeConfig = config.theme || config.themeConfig || {}
|
|
28
28
|
|
|
29
29
|
const hasTabs = themeConfig?.tabs && themeConfig.tabs.length > 0
|
|
30
30
|
|
|
@@ -76,10 +76,10 @@ export function Navbar() {
|
|
|
76
76
|
</NavbarPrimitive.NavbarRight>
|
|
77
77
|
</NavbarPrimitive.Content>
|
|
78
78
|
|
|
79
|
-
{pathname !== '/' && hasTabs &&
|
|
79
|
+
{pathname !== '/' && hasTabs && themeConfig?.tabs && (
|
|
80
80
|
<div className="w-full border-b border-border-subtle bg-bg-main">
|
|
81
81
|
<Tabs
|
|
82
|
-
tabs={
|
|
82
|
+
tabs={themeConfig.tabs}
|
|
83
83
|
routes={allRoutes || routes || []}
|
|
84
84
|
/>
|
|
85
85
|
</div>
|
|
@@ -67,6 +67,7 @@ export function Sidebar({
|
|
|
67
67
|
config: BoltdocsConfig
|
|
68
68
|
}) {
|
|
69
69
|
const { groups, ungrouped, activePath } = useSidebar(routes)
|
|
70
|
+
const themeConfig = config.theme || config.themeConfig || {}
|
|
70
71
|
|
|
71
72
|
return (
|
|
72
73
|
<SidebarPrimitive.SidebarRoot>
|
|
@@ -94,7 +95,7 @@ export function Sidebar({
|
|
|
94
95
|
/>
|
|
95
96
|
))}
|
|
96
97
|
|
|
97
|
-
{
|
|
98
|
+
{themeConfig?.poweredBy && (
|
|
98
99
|
<div className="mt-auto pt-8">
|
|
99
100
|
<PoweredBy />
|
|
100
101
|
</div>
|
|
@@ -8,7 +8,7 @@ export function useNavbar() {
|
|
|
8
8
|
const { theme } = useTheme()
|
|
9
9
|
const location = useLocation()
|
|
10
10
|
|
|
11
|
-
const themeConfig = config.themeConfig || {}
|
|
11
|
+
const themeConfig = config.theme || config.themeConfig || {}
|
|
12
12
|
const title = themeConfig.title || 'Boltdocs'
|
|
13
13
|
const rawLinks = themeConfig.navbar || []
|
|
14
14
|
const socialLinks = themeConfig.socialLinks || []
|
package/src/client/types.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface CreateBoltdocsAppOptions {
|
|
|
62
62
|
/** Site configuration (`virtual:boltdocs-config`) */
|
|
63
63
|
config: SiteConfig
|
|
64
64
|
/** Dynamic import mapping from `import.meta.glob` for the documentation pages */
|
|
65
|
-
modules: Record<string, () => Promise<{ default: React.ComponentType }>>
|
|
65
|
+
modules: Record<string, () => Promise<{ default: React.ComponentType<any> }>>
|
|
66
66
|
/** The `import.meta.hot` instance necessary for fast refresh/HMR updates */
|
|
67
67
|
hot?: {
|
|
68
68
|
accept: (cb?: (mod: any) => void) => void
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import cac from "cac";
|
|
3
|
+
import { devAction, buildAction, previewAction } from "./cli";
|
|
4
|
+
|
|
5
|
+
const cli = cac("boltdocs");
|
|
6
|
+
|
|
7
|
+
cli
|
|
8
|
+
.command("[root]", "Start development server")
|
|
9
|
+
.alias("dev")
|
|
10
|
+
.action(devAction);
|
|
11
|
+
|
|
12
|
+
cli
|
|
13
|
+
.command("build [root]", "Build for production")
|
|
14
|
+
.action(buildAction);
|
|
15
|
+
|
|
16
|
+
cli
|
|
17
|
+
.command("preview [root]", "Preview production build")
|
|
18
|
+
.action(previewAction);
|
|
19
|
+
|
|
20
|
+
cli.help();
|
|
21
|
+
// This will be replaced at build time or package publishing, but hardcoded to 2.0.0 for now
|
|
22
|
+
cli.version("2.0.0");
|
|
23
|
+
|
|
24
|
+
cli.parse();
|
package/src/node/cli.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createServer, build, preview } from 'vite'
|
|
2
|
+
import { createViteConfig, resolveConfig } from './index'
|
|
3
|
+
import { getHtmlTemplate } from './plugin/html'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import fs from 'fs'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Core logic for the Boltdocs CLI commands.
|
|
9
|
+
* These functions wrap Vite's JS API to provide a seamless experience.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export async function devAction(root: string = process.cwd()) {
|
|
13
|
+
try {
|
|
14
|
+
const viteConfig = await createViteConfig(root, 'development')
|
|
15
|
+
const server = await createServer(viteConfig)
|
|
16
|
+
await server.listen()
|
|
17
|
+
server.printUrls()
|
|
18
|
+
server.bindCLIShortcuts({ print: true })
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error('[boltdocs] Failed to start dev server:', e)
|
|
21
|
+
process.exit(1)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function buildAction(root: string = process.cwd()) {
|
|
26
|
+
let createdIndexHtml = false
|
|
27
|
+
const indexPath = path.resolve(root, 'index.html')
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
if (!fs.existsSync(indexPath)) {
|
|
31
|
+
const config = await resolveConfig('docs', root)
|
|
32
|
+
fs.writeFileSync(indexPath, getHtmlTemplate(config), 'utf-8')
|
|
33
|
+
createdIndexHtml = true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const viteConfig = await createViteConfig(root, 'production')
|
|
37
|
+
await build(viteConfig)
|
|
38
|
+
console.log('[boltdocs] Build completed successfully.')
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error('[boltdocs] Build failed:', e)
|
|
41
|
+
process.exit(1)
|
|
42
|
+
} finally {
|
|
43
|
+
if (createdIndexHtml && fs.existsSync(indexPath)) {
|
|
44
|
+
fs.unlinkSync(indexPath)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function previewAction(root: string = process.cwd()) {
|
|
50
|
+
try {
|
|
51
|
+
const viteConfig = await createViteConfig(root, 'production')
|
|
52
|
+
const previewServer = await preview(viteConfig)
|
|
53
|
+
previewServer.printUrls()
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.error('[boltdocs] Failed to start preview server:', e)
|
|
56
|
+
process.exit(1)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|