boltdocs 1.10.2 → 2.0.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 +7 -0
- package/LICENSE +21 -0
- package/dist/cache-7G6D532T.mjs +1 -0
- package/dist/chunk-A4HQPEPU.mjs +1 -0
- package/dist/chunk-BA5NH5HU.mjs +1 -0
- package/dist/chunk-BQCD3DWG.mjs +1 -0
- package/dist/chunk-H63UMKYF.mjs +1 -0
- package/dist/chunk-IWHRQHS7.mjs +1 -0
- package/dist/chunk-JZXLCA2E.mjs +1 -0
- package/dist/chunk-MFU7Q6WF.mjs +1 -0
- package/dist/chunk-QYPNX5UN.mjs +1 -0
- package/dist/chunk-XEAPSFMB.mjs +1 -0
- package/dist/client/components/mdx/index.d.mts +209 -0
- package/dist/client/components/mdx/index.d.ts +209 -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 +133 -0
- package/dist/client/hooks/index.d.ts +133 -0
- package/dist/client/hooks/index.js +1 -0
- package/dist/client/hooks/index.mjs +1 -0
- package/dist/client/index.d.mts +138 -298
- package/dist/client/index.d.ts +138 -298
- package/dist/client/index.js +1 -3630
- package/dist/client/index.mjs +1 -697
- package/dist/client/ssr.d.mts +7 -3
- package/dist/client/ssr.d.ts +7 -3
- package/dist/client/ssr.js +1 -2928
- package/dist/client/ssr.mjs +1 -33
- package/dist/{config-BsFQ-ErD.d.ts → config-CX4l-ZNp.d.mts} +42 -35
- package/dist/{config-BsFQ-ErD.d.mts → config-CX4l-ZNp.d.ts} +42 -35
- package/dist/node/index.d.mts +2 -4
- package/dist/node/index.d.ts +2 -4
- package/dist/node/index.js +31 -1161
- package/dist/node/index.mjs +31 -736
- package/dist/search-dialog-EB3N4TYM.mjs +1 -0
- package/dist/types-BuZWFT7r.d.ts +159 -0
- package/dist/types-CvT-SGbK.d.mts +159 -0
- package/dist/use-routes-5bAtAAYX.d.mts +30 -0
- package/dist/use-routes-BefRXY3v.d.ts +30 -0
- package/package.json +34 -12
- package/src/client/app/config-context.tsx +18 -0
- package/src/client/app/docs-layout.tsx +14 -0
- package/src/client/app/index.tsx +137 -262
- package/src/client/app/mdx-component.tsx +52 -0
- package/src/client/app/mdx-components-context.tsx +23 -0
- package/src/client/app/mdx-page.tsx +20 -0
- package/src/client/app/preload.tsx +38 -30
- package/src/client/app/router.tsx +30 -0
- package/src/client/app/scroll-handler.tsx +40 -0
- package/src/client/app/theme-context.tsx +75 -0
- package/src/client/components/default-layout.tsx +80 -0
- package/src/client/components/docs-layout.tsx +105 -0
- package/src/client/components/icons-dev.tsx +74 -0
- package/src/client/components/mdx/admonition.tsx +107 -0
- package/src/client/components/mdx/badge.tsx +41 -0
- package/src/client/components/mdx/button.tsx +35 -0
- package/src/client/components/mdx/card.tsx +124 -0
- package/src/client/components/mdx/code-block.tsx +119 -0
- package/src/client/components/mdx/component-preview.tsx +47 -0
- package/src/client/components/mdx/component-props.tsx +83 -0
- package/src/client/components/mdx/field.tsx +66 -0
- package/src/client/components/mdx/file-tree.tsx +287 -0
- package/src/client/components/mdx/hooks/use-code-block.ts +56 -0
- package/src/client/components/mdx/hooks/use-component-preview.ts +16 -0
- package/src/client/components/mdx/hooks/useTable.ts +74 -0
- package/src/client/components/mdx/hooks/useTabs.ts +68 -0
- package/src/client/components/mdx/image.tsx +23 -0
- package/src/client/components/mdx/index.ts +53 -0
- package/src/client/components/mdx/link.tsx +38 -0
- package/src/client/components/mdx/list.tsx +192 -0
- package/src/client/components/mdx/table.tsx +156 -0
- package/src/client/components/mdx/tabs.tsx +135 -0
- package/src/client/components/mdx/video.tsx +68 -0
- package/src/client/components/primitives/breadcrumbs.tsx +79 -0
- package/src/client/components/primitives/button-group.tsx +54 -0
- package/src/client/components/primitives/button.tsx +145 -0
- package/src/client/components/primitives/helpers/observer.ts +120 -0
- package/src/client/components/primitives/index.ts +17 -0
- package/src/client/components/primitives/link.tsx +122 -0
- package/src/client/components/primitives/menu.tsx +159 -0
- package/src/client/components/primitives/navbar.tsx +359 -0
- package/src/client/components/primitives/navigation-menu.tsx +116 -0
- package/src/client/components/primitives/on-this-page.tsx +461 -0
- package/src/client/components/primitives/page-nav.tsx +87 -0
- package/src/client/components/primitives/popover.tsx +47 -0
- package/src/client/components/primitives/search-dialog.tsx +183 -0
- package/src/client/components/primitives/sidebar.tsx +154 -0
- package/src/client/components/primitives/tabs.tsx +90 -0
- package/src/client/components/primitives/tooltip.tsx +83 -0
- package/src/client/components/primitives/types.ts +11 -0
- package/src/client/components/ui-base/breadcrumbs.tsx +42 -0
- package/src/client/components/ui-base/copy-markdown.tsx +112 -0
- package/src/client/components/ui-base/error-boundary.tsx +52 -0
- package/src/client/components/ui-base/github-stars.tsx +27 -0
- package/src/client/components/ui-base/head.tsx +69 -0
- package/src/client/components/ui-base/loading.tsx +87 -0
- package/src/client/components/ui-base/navbar.tsx +138 -0
- package/src/client/components/ui-base/not-found.tsx +24 -0
- package/src/client/components/ui-base/on-this-page.tsx +152 -0
- package/src/client/components/ui-base/page-nav.tsx +39 -0
- package/src/client/components/ui-base/powered-by.tsx +19 -0
- package/src/client/components/ui-base/progress-bar.tsx +67 -0
- package/src/client/components/ui-base/search-dialog.tsx +82 -0
- package/src/client/components/ui-base/sidebar.tsx +104 -0
- package/src/client/components/ui-base/tabs.tsx +65 -0
- package/src/client/components/ui-base/theme-toggle.tsx +32 -0
- package/src/client/hooks/index.ts +12 -0
- package/src/client/hooks/use-breadcrumbs.ts +22 -0
- package/src/client/hooks/use-i18n.ts +84 -0
- package/src/client/hooks/use-localized-to.ts +95 -0
- package/src/client/hooks/use-location.ts +5 -0
- package/src/client/hooks/use-navbar.ts +60 -0
- package/src/client/hooks/use-onthispage.ts +23 -0
- package/src/client/hooks/use-page-nav.ts +22 -0
- package/src/client/hooks/use-routes.ts +72 -0
- package/src/client/hooks/use-search.ts +71 -0
- package/src/client/hooks/use-sidebar.ts +49 -0
- package/src/client/hooks/use-tabs.ts +43 -0
- package/src/client/hooks/use-version.ts +78 -0
- package/src/client/index.ts +55 -17
- package/src/client/integrations/codesandbox.ts +179 -0
- package/src/client/ssr.tsx +27 -16
- package/src/client/theme/neutral.css +360 -0
- package/src/client/types.ts +131 -27
- package/src/client/utils/cn.ts +6 -0
- package/src/client/utils/copy-clipboard.ts +22 -0
- package/src/client/utils/get-base-file-path.ts +21 -0
- package/src/client/utils/github.ts +121 -0
- package/src/client/utils/use-on-change.ts +15 -0
- package/src/client/virtual.d.ts +24 -0
- package/src/node/cache.ts +156 -156
- package/src/node/config.ts +159 -103
- package/src/node/index.ts +13 -13
- package/src/node/mdx.ts +213 -61
- package/src/node/plugin/entry.ts +29 -18
- package/src/node/plugin/html.ts +11 -11
- package/src/node/plugin/index.ts +161 -84
- package/src/node/plugin/types.ts +2 -4
- package/src/node/routes/cache.ts +6 -6
- package/src/node/routes/index.ts +206 -113
- package/src/node/routes/parser.ts +102 -82
- package/src/node/routes/sorter.ts +15 -15
- package/src/node/routes/types.ts +24 -24
- package/src/node/ssg/index.ts +73 -47
- package/src/node/ssg/meta.ts +4 -4
- package/src/node/ssg/options.ts +5 -5
- package/src/node/ssg/sitemap.ts +14 -14
- package/src/node/utils.ts +54 -31
- package/tsconfig.json +25 -20
- package/tsup.config.ts +23 -14
- package/dist/PackageManagerTabs-NVT7G625.mjs +0 -99
- package/dist/SearchDialog-AGVF6JBO.mjs +0 -194
- package/dist/SearchDialog-YPDOM7Q6.css +0 -2847
- package/dist/Video-KNTY5BNO.mjs +0 -6
- package/dist/cache-KNL5B4EE.mjs +0 -12
- package/dist/chunk-7SFUJWTB.mjs +0 -211
- package/dist/chunk-FFBNU6IJ.mjs +0 -386
- package/dist/chunk-FMTOYQLO.mjs +0 -37
- package/dist/chunk-TKLQWU7H.mjs +0 -1920
- package/dist/chunk-Z7JHYNAS.mjs +0 -57
- package/dist/client/index.css +0 -2847
- package/dist/client/ssr.css +0 -2847
- package/dist/types-Dj-bfnC3.d.mts +0 -74
- package/dist/types-Dj-bfnC3.d.ts +0 -74
- package/src/client/theme/components/CodeBlock/CodeBlock.tsx +0 -61
- package/src/client/theme/components/CodeBlock/index.ts +0 -1
- package/src/client/theme/components/PackageManagerTabs/PackageManagerTabs.tsx +0 -131
- package/src/client/theme/components/PackageManagerTabs/index.ts +0 -1
- package/src/client/theme/components/PackageManagerTabs/pkg-tabs.css +0 -64
- package/src/client/theme/components/Playground/Playground.tsx +0 -180
- package/src/client/theme/components/Playground/index.ts +0 -1
- package/src/client/theme/components/Playground/playground.css +0 -238
- package/src/client/theme/components/Video/Video.tsx +0 -84
- package/src/client/theme/components/Video/index.ts +0 -1
- package/src/client/theme/components/Video/video.css +0 -41
- package/src/client/theme/components/mdx/Admonition.tsx +0 -80
- package/src/client/theme/components/mdx/Badge.tsx +0 -31
- package/src/client/theme/components/mdx/Button.tsx +0 -50
- package/src/client/theme/components/mdx/Card.tsx +0 -80
- package/src/client/theme/components/mdx/Field.tsx +0 -60
- package/src/client/theme/components/mdx/FileTree.tsx +0 -229
- package/src/client/theme/components/mdx/List.tsx +0 -57
- package/src/client/theme/components/mdx/Table.tsx +0 -151
- package/src/client/theme/components/mdx/Tabs.tsx +0 -123
- package/src/client/theme/components/mdx/index.ts +0 -27
- package/src/client/theme/components/mdx/mdx-components.css +0 -764
- package/src/client/theme/icons/bun.tsx +0 -62
- package/src/client/theme/icons/deno.tsx +0 -20
- package/src/client/theme/icons/discord.tsx +0 -12
- package/src/client/theme/icons/github.tsx +0 -15
- package/src/client/theme/icons/npm.tsx +0 -13
- package/src/client/theme/icons/pnpm.tsx +0 -72
- package/src/client/theme/icons/twitter.tsx +0 -12
- package/src/client/theme/styles/markdown.css +0 -394
- package/src/client/theme/styles/variables.css +0 -175
- package/src/client/theme/styles.css +0 -39
- package/src/client/theme/ui/Breadcrumbs/Breadcrumbs.tsx +0 -68
- package/src/client/theme/ui/Breadcrumbs/index.ts +0 -1
- package/src/client/theme/ui/CopyMarkdown/CopyMarkdown.tsx +0 -82
- package/src/client/theme/ui/CopyMarkdown/copy-markdown.css +0 -112
- package/src/client/theme/ui/CopyMarkdown/index.ts +0 -1
- package/src/client/theme/ui/ErrorBoundary/ErrorBoundary.tsx +0 -50
- package/src/client/theme/ui/ErrorBoundary/error-boundary.css +0 -55
- package/src/client/theme/ui/ErrorBoundary/index.ts +0 -1
- package/src/client/theme/ui/Footer/footer.css +0 -32
- package/src/client/theme/ui/Head/Head.tsx +0 -69
- package/src/client/theme/ui/Head/index.ts +0 -1
- package/src/client/theme/ui/LanguageSwitcher/LanguageSwitcher.tsx +0 -125
- package/src/client/theme/ui/LanguageSwitcher/index.ts +0 -1
- package/src/client/theme/ui/LanguageSwitcher/language-switcher.css +0 -98
- package/src/client/theme/ui/Layout/Layout.tsx +0 -203
- package/src/client/theme/ui/Layout/base.css +0 -106
- package/src/client/theme/ui/Layout/index.ts +0 -2
- package/src/client/theme/ui/Layout/pagination.css +0 -72
- package/src/client/theme/ui/Layout/responsive.css +0 -47
- package/src/client/theme/ui/Link/Link.tsx +0 -392
- package/src/client/theme/ui/Link/LinkPreview.tsx +0 -59
- package/src/client/theme/ui/Link/index.ts +0 -2
- package/src/client/theme/ui/Link/link-preview.css +0 -48
- package/src/client/theme/ui/Loading/Loading.tsx +0 -10
- package/src/client/theme/ui/Loading/index.ts +0 -1
- package/src/client/theme/ui/Loading/loading.css +0 -30
- package/src/client/theme/ui/Navbar/GithubStars.tsx +0 -27
- package/src/client/theme/ui/Navbar/Navbar.tsx +0 -193
- package/src/client/theme/ui/Navbar/Tabs.tsx +0 -99
- package/src/client/theme/ui/Navbar/index.ts +0 -2
- package/src/client/theme/ui/Navbar/navbar.css +0 -347
- package/src/client/theme/ui/NotFound/NotFound.tsx +0 -19
- package/src/client/theme/ui/NotFound/index.ts +0 -1
- package/src/client/theme/ui/NotFound/not-found.css +0 -64
- package/src/client/theme/ui/OnThisPage/OnThisPage.tsx +0 -244
- package/src/client/theme/ui/OnThisPage/index.ts +0 -1
- package/src/client/theme/ui/OnThisPage/toc.css +0 -152
- package/src/client/theme/ui/PoweredBy/PoweredBy.tsx +0 -18
- package/src/client/theme/ui/PoweredBy/index.ts +0 -1
- package/src/client/theme/ui/PoweredBy/powered-by.css +0 -76
- package/src/client/theme/ui/ProgressBar/ProgressBar.css +0 -17
- package/src/client/theme/ui/ProgressBar/ProgressBar.tsx +0 -51
- package/src/client/theme/ui/ProgressBar/index.ts +0 -1
- package/src/client/theme/ui/SearchDialog/SearchDialog.tsx +0 -209
- package/src/client/theme/ui/SearchDialog/index.ts +0 -1
- package/src/client/theme/ui/SearchDialog/search.css +0 -152
- package/src/client/theme/ui/Sidebar/Sidebar.tsx +0 -244
- package/src/client/theme/ui/Sidebar/index.ts +0 -1
- package/src/client/theme/ui/Sidebar/sidebar.css +0 -230
- package/src/client/theme/ui/ThemeToggle/ThemeToggle.tsx +0 -69
- package/src/client/theme/ui/ThemeToggle/index.ts +0 -1
- package/src/client/theme/ui/VersionSwitcher/VersionSwitcher.tsx +0 -136
- package/src/client/theme/ui/VersionSwitcher/index.ts +0 -1
- package/src/client/utils.ts +0 -49
package/src/node/config.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type { Plugin as VitePlugin } from "vite";
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import { loadConfigFromFile, type Plugin as VitePlugin } from 'vite'
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Represents a single social link in the configuration.
|
|
8
7
|
*/
|
|
9
8
|
export interface BoltdocsSocialLink {
|
|
10
|
-
/** Identifier for the icon (e.g., 'github'
|
|
11
|
-
icon:
|
|
9
|
+
/** Identifier for the icon (e.g., 'github') */
|
|
10
|
+
icon: 'discord' | 'x' | 'github' | 'bluesky' | string
|
|
12
11
|
/** The URL the social link points to */
|
|
13
|
-
link: string
|
|
12
|
+
link: string
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -18,7 +17,7 @@ export interface BoltdocsSocialLink {
|
|
|
18
17
|
*/
|
|
19
18
|
export interface BoltdocsFooterConfig {
|
|
20
19
|
/** Text to display in the footer (HTML is supported) */
|
|
21
|
-
text?: string
|
|
20
|
+
text?: string
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -26,77 +25,64 @@ export interface BoltdocsFooterConfig {
|
|
|
26
25
|
*/
|
|
27
26
|
export interface BoltdocsThemeConfig {
|
|
28
27
|
/** The global title of the documentation site */
|
|
29
|
-
title?: string
|
|
28
|
+
title?: string
|
|
30
29
|
/** The global description of the site (used for SEO) */
|
|
31
|
-
description?: string
|
|
32
|
-
/** URL path to the site logo */
|
|
33
|
-
logo?:
|
|
30
|
+
description?: string
|
|
31
|
+
/** URL path to the site logo or an object for light/dark versions */
|
|
32
|
+
logo?:
|
|
33
|
+
| string
|
|
34
|
+
| {
|
|
35
|
+
dark: string
|
|
36
|
+
light: string
|
|
37
|
+
alt?: string
|
|
38
|
+
width?: number
|
|
39
|
+
height?: number
|
|
40
|
+
}
|
|
34
41
|
/** Items to display in the top navigation bar */
|
|
35
42
|
navbar?: Array<{
|
|
36
|
-
/** Text to display (alias for text) */
|
|
37
|
-
label?: string;
|
|
38
43
|
/** Text to display */
|
|
39
|
-
|
|
40
|
-
/** URL path or external link (alias for link) */
|
|
41
|
-
to?: string;
|
|
42
|
-
/** URL path or external link (alias for link) */
|
|
43
|
-
href?: string;
|
|
44
|
+
label: string
|
|
44
45
|
/** URL path or external link */
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
}
|
|
46
|
+
href: string
|
|
47
|
+
/** Nested items for NavigationMenu */
|
|
48
|
+
items?: Array<{ label: string; href: string }>
|
|
49
|
+
}>
|
|
49
50
|
/** Items to display in the sidebar, organized optionally by group URLs */
|
|
50
|
-
sidebar?: Record<string, Array<{ text: string; link: string }
|
|
51
|
+
sidebar?: Record<string, Array<{ text: string; link: string }>>
|
|
51
52
|
/** Social links to display in the navigation bar */
|
|
52
|
-
socialLinks?: BoltdocsSocialLink[]
|
|
53
|
+
socialLinks?: BoltdocsSocialLink[]
|
|
53
54
|
/** Site footer configuration */
|
|
54
|
-
footer?: BoltdocsFooterConfig
|
|
55
|
+
footer?: BoltdocsFooterConfig
|
|
55
56
|
/** Whether to show breadcrumbs navigation (default: true) */
|
|
56
|
-
breadcrumbs?: boolean
|
|
57
|
-
/** Path to a custom CSS file that overrides theme variables */
|
|
58
|
-
customCss?: string;
|
|
57
|
+
breadcrumbs?: boolean
|
|
59
58
|
/** URL template for 'Edit this page'. Use :path as a placeholder. */
|
|
60
|
-
editLink?: string
|
|
59
|
+
editLink?: string
|
|
61
60
|
/** URL for the 'Community help' link. */
|
|
62
|
-
communityHelp?: string
|
|
61
|
+
communityHelp?: string
|
|
63
62
|
/** The current version of the project (e.g., 'v2.8.9'). Displayed in the Navbar. */
|
|
64
|
-
version?: string
|
|
63
|
+
version?: string
|
|
65
64
|
/** The GitHub repository in the format 'owner/repo' to fetch and display star count. */
|
|
66
|
-
githubRepo?: string
|
|
65
|
+
githubRepo?: string
|
|
67
66
|
/** Whether to show the 'Powered by LiteDocs' badge in the sidebar (default: true) */
|
|
68
|
-
poweredBy?: boolean
|
|
69
|
-
/** Whether to show a preview tooltip on internal links hover (default: true) */
|
|
70
|
-
linkPreview?: boolean;
|
|
71
|
-
/** Granular layout customization props */
|
|
72
|
-
layoutProps?: {
|
|
73
|
-
navbar?: any;
|
|
74
|
-
sidebar?: any;
|
|
75
|
-
toc?: any;
|
|
76
|
-
background?: any;
|
|
77
|
-
head?: any;
|
|
78
|
-
breadcrumbs?: any;
|
|
79
|
-
className?: string;
|
|
80
|
-
style?: any;
|
|
81
|
-
};
|
|
67
|
+
poweredBy?: boolean
|
|
82
68
|
/**
|
|
83
69
|
* Top-level tabs for organizing documentation groups.
|
|
84
70
|
* Tab discovery uses the (tab-id) directory syntax.
|
|
85
71
|
*/
|
|
86
|
-
tabs?: Array<{ id: string; text: string; icon?: string }
|
|
72
|
+
tabs?: Array<{ id: string; text: string; icon?: string }>
|
|
87
73
|
/**
|
|
88
74
|
* The syntax highlighting theme for code blocks.
|
|
89
75
|
* Supports any Shiki theme name (e.g., 'github-dark', 'one-dark-pro', 'aurora-x').
|
|
90
76
|
* Can also be an object for multiple themes (e.g., { light: 'github-light', dark: 'github-dark' }).
|
|
91
|
-
* Default: 'one-dark-pro'
|
|
77
|
+
* Default: { light: 'github-light', dark: 'one-dark-pro' }
|
|
92
78
|
*/
|
|
93
|
-
codeTheme?: string |
|
|
79
|
+
codeTheme?: string | { light: string; dark: string }
|
|
94
80
|
/**
|
|
95
81
|
* Configuration for the 'Copy Markdown' button.
|
|
96
82
|
* Can be a boolean or an object with text and icon.
|
|
97
83
|
* Default: true
|
|
98
84
|
*/
|
|
99
|
-
copyMarkdown?: boolean | { text?: string; icon?: string }
|
|
85
|
+
copyMarkdown?: boolean | { text?: string; icon?: string }
|
|
100
86
|
}
|
|
101
87
|
|
|
102
88
|
/**
|
|
@@ -104,9 +90,9 @@ export interface BoltdocsThemeConfig {
|
|
|
104
90
|
*/
|
|
105
91
|
export interface BoltdocsI18nConfig {
|
|
106
92
|
/** The default locale (e.g., 'en') */
|
|
107
|
-
defaultLocale: string
|
|
93
|
+
defaultLocale: string
|
|
108
94
|
/** Available locales and their display names (e.g., { en: 'English', es: 'Español' }) */
|
|
109
|
-
locales: Record<string, string
|
|
95
|
+
locales: Record<string, string>
|
|
110
96
|
}
|
|
111
97
|
|
|
112
98
|
/**
|
|
@@ -114,9 +100,9 @@ export interface BoltdocsI18nConfig {
|
|
|
114
100
|
*/
|
|
115
101
|
export interface BoltdocsVersionsConfig {
|
|
116
102
|
/** The default version (e.g., 'v2') */
|
|
117
|
-
defaultVersion: string
|
|
103
|
+
defaultVersion: string
|
|
118
104
|
/** Available versions and their display names (e.g., { v1: 'Version 1.x', v2: 'Version 2.x' }) */
|
|
119
|
-
versions: Record<string, string
|
|
105
|
+
versions: Record<string, string>
|
|
120
106
|
}
|
|
121
107
|
|
|
122
108
|
/**
|
|
@@ -124,17 +110,30 @@ export interface BoltdocsVersionsConfig {
|
|
|
124
110
|
*/
|
|
125
111
|
export interface BoltdocsPlugin {
|
|
126
112
|
/** A unique name for the plugin */
|
|
127
|
-
name: string
|
|
113
|
+
name: string
|
|
128
114
|
/** Whether to run this plugin before or after default ones (optional) */
|
|
129
|
-
enforce?:
|
|
115
|
+
enforce?: 'pre' | 'post'
|
|
130
116
|
/** Optional remark plugins to add to the MDX pipeline */
|
|
131
|
-
remarkPlugins?:
|
|
117
|
+
remarkPlugins?: unknown[]
|
|
132
118
|
/** Optional rehype plugins to add to the MDX pipeline */
|
|
133
|
-
rehypePlugins?:
|
|
119
|
+
rehypePlugins?: unknown[]
|
|
134
120
|
/** Optional Vite plugins to inject into the build process */
|
|
135
|
-
vitePlugins?: VitePlugin[]
|
|
121
|
+
vitePlugins?: VitePlugin[]
|
|
136
122
|
/** Optional custom React components to register in MDX. Map of Name -> Module Path. */
|
|
137
|
-
components?: Record<string, string
|
|
123
|
+
components?: Record<string, string>
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Configuration for external integrations (e.g., CodeSandbox).
|
|
128
|
+
*/
|
|
129
|
+
export interface BoltdocsIntegrationsConfig {
|
|
130
|
+
/** CodeSandbox integration settings */
|
|
131
|
+
sandbox?: {
|
|
132
|
+
/** Whether to enable the "Open in Sandbox" button in CodeBlocks */
|
|
133
|
+
enable?: boolean
|
|
134
|
+
/** Default options for the sandbox (files, dependencies, etc.) */
|
|
135
|
+
config?: Record<string, unknown>
|
|
136
|
+
}
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
/**
|
|
@@ -142,24 +141,35 @@ export interface BoltdocsPlugin {
|
|
|
142
141
|
*/
|
|
143
142
|
export interface BoltdocsConfig {
|
|
144
143
|
/** The base URL of the site, used for generating the sitemap */
|
|
145
|
-
siteUrl?: string
|
|
144
|
+
siteUrl?: string
|
|
146
145
|
/** Configuration pertaining to the UI and appearance */
|
|
147
|
-
themeConfig?: BoltdocsThemeConfig
|
|
146
|
+
themeConfig?: BoltdocsThemeConfig
|
|
148
147
|
/** The root directory containing markdown documentation files (default: 'docs') */
|
|
149
|
-
docsDir?: string
|
|
148
|
+
docsDir?: string
|
|
150
149
|
/** Configuration for internationalization */
|
|
151
|
-
i18n?: BoltdocsI18nConfig
|
|
150
|
+
i18n?: BoltdocsI18nConfig
|
|
152
151
|
/** Configuration for documentation versioning */
|
|
153
|
-
versions?: BoltdocsVersionsConfig
|
|
152
|
+
versions?: BoltdocsVersionsConfig
|
|
154
153
|
/** Custom plugins for extending functionality */
|
|
155
|
-
plugins?: BoltdocsPlugin[]
|
|
154
|
+
plugins?: BoltdocsPlugin[]
|
|
155
|
+
/** Map of custom external route paths to component file paths */
|
|
156
|
+
external?: Record<string, string>
|
|
157
|
+
/** External integrations configuration */
|
|
158
|
+
integrations?: BoltdocsIntegrationsConfig
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
export const CONFIG_FILES = [
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
]
|
|
162
|
+
'boltdocs.config.js',
|
|
163
|
+
'boltdocs.config.mjs',
|
|
164
|
+
'boltdocs.config.ts',
|
|
165
|
+
]
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Small helper to handle partial config objects from user input.
|
|
169
|
+
*/
|
|
170
|
+
interface RawUserConfig
|
|
171
|
+
extends Partial<BoltdocsConfig>,
|
|
172
|
+
Partial<BoltdocsThemeConfig> {}
|
|
163
173
|
|
|
164
174
|
/**
|
|
165
175
|
* Loads user's configuration file (e.g., `boltdocs.config.js` or `boltdocs.config.ts`) if it exists,
|
|
@@ -173,53 +183,99 @@ export async function resolveConfig(
|
|
|
173
183
|
docsDir: string,
|
|
174
184
|
root: string = process.cwd(),
|
|
175
185
|
): Promise<BoltdocsConfig> {
|
|
176
|
-
const projectRoot = root
|
|
186
|
+
const projectRoot = root
|
|
177
187
|
|
|
178
188
|
const defaults: BoltdocsConfig = {
|
|
179
189
|
docsDir: path.resolve(docsDir),
|
|
180
190
|
themeConfig: {
|
|
181
|
-
title:
|
|
182
|
-
description:
|
|
191
|
+
title: 'Boltdocs',
|
|
192
|
+
description: 'A Vite documentation framework',
|
|
183
193
|
navbar: [
|
|
184
|
-
{
|
|
185
|
-
{
|
|
194
|
+
{ label: 'Home', href: '/' },
|
|
195
|
+
{ label: 'Documentation', href: '/docs' },
|
|
186
196
|
],
|
|
197
|
+
codeTheme: {
|
|
198
|
+
light: 'github-light',
|
|
199
|
+
dark: 'github-dark',
|
|
200
|
+
},
|
|
201
|
+
poweredBy: true,
|
|
202
|
+
breadcrumbs: true,
|
|
187
203
|
},
|
|
188
|
-
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let userConfig: RawUserConfig = {}
|
|
189
207
|
|
|
190
208
|
// Try to load user config
|
|
191
209
|
for (const filename of CONFIG_FILES) {
|
|
192
|
-
const configPath = path.resolve(projectRoot, filename)
|
|
210
|
+
const configPath = path.resolve(projectRoot, filename)
|
|
193
211
|
if (fs.existsSync(configPath)) {
|
|
194
212
|
try {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// Support new format where user exports BoltdocsConfig directly
|
|
205
|
-
const userThemeConfig = userConfig.themeConfig || userConfig;
|
|
206
|
-
|
|
207
|
-
return {
|
|
208
|
-
docsDir: path.resolve(docsDir),
|
|
209
|
-
themeConfig: {
|
|
210
|
-
...defaults.themeConfig,
|
|
211
|
-
...userThemeConfig,
|
|
212
|
-
},
|
|
213
|
-
i18n: userConfig.i18n,
|
|
214
|
-
versions: userConfig.versions,
|
|
215
|
-
siteUrl: userConfig.siteUrl,
|
|
216
|
-
plugins: userConfig.plugins || [],
|
|
217
|
-
};
|
|
213
|
+
const loaded = await loadConfigFromFile(
|
|
214
|
+
{ command: 'serve', mode: 'development' },
|
|
215
|
+
configPath,
|
|
216
|
+
projectRoot,
|
|
217
|
+
)
|
|
218
|
+
if (loaded) {
|
|
219
|
+
userConfig = loaded.config as RawUserConfig
|
|
220
|
+
break
|
|
221
|
+
}
|
|
218
222
|
} catch (e) {
|
|
219
|
-
console.warn(`[boltdocs] Failed to load config from ${filename}:`, e)
|
|
223
|
+
console.warn(`[boltdocs] Failed to load config from ${filename}:`, e)
|
|
220
224
|
}
|
|
221
225
|
}
|
|
222
226
|
}
|
|
223
227
|
|
|
224
|
-
|
|
228
|
+
// Robust merging strategy
|
|
229
|
+
const themeConfigFromTop: BoltdocsThemeConfig = {
|
|
230
|
+
title: userConfig.title,
|
|
231
|
+
description: userConfig.description,
|
|
232
|
+
logo: userConfig.logo,
|
|
233
|
+
navbar: userConfig.navbar,
|
|
234
|
+
sidebar: userConfig.sidebar,
|
|
235
|
+
socialLinks: userConfig.socialLinks,
|
|
236
|
+
footer: userConfig.footer,
|
|
237
|
+
githubRepo: userConfig.githubRepo,
|
|
238
|
+
tabs: userConfig.tabs,
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// User can define properties at top level or inside themeConfig
|
|
242
|
+
const userThemeConfig: BoltdocsThemeConfig = {
|
|
243
|
+
...themeConfigFromTop,
|
|
244
|
+
...(userConfig.themeConfig || {}),
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Clean undefined properties
|
|
248
|
+
const cleanThemeConfig = Object.fromEntries(
|
|
249
|
+
Object.entries(userThemeConfig).filter(([_, v]) => v !== undefined),
|
|
250
|
+
) as BoltdocsThemeConfig
|
|
251
|
+
|
|
252
|
+
// Transform old navbar items if necessary
|
|
253
|
+
if (cleanThemeConfig.navbar) {
|
|
254
|
+
cleanThemeConfig.navbar = cleanThemeConfig.navbar.map((item: any) => ({
|
|
255
|
+
label: item.label || item.text || '',
|
|
256
|
+
href: item.href || item.link || item.to || '',
|
|
257
|
+
items: item.items?.map((sub: any) => ({
|
|
258
|
+
label: sub.label || sub.text || '',
|
|
259
|
+
href: sub.href || sub.link || sub.to || '',
|
|
260
|
+
})),
|
|
261
|
+
}))
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
docsDir: path.resolve(docsDir),
|
|
266
|
+
themeConfig: {
|
|
267
|
+
...defaults.themeConfig,
|
|
268
|
+
...cleanThemeConfig,
|
|
269
|
+
codeTheme:
|
|
270
|
+
cleanThemeConfig.codeTheme ||
|
|
271
|
+
(userConfig.themeConfig || userConfig).codeTheme ||
|
|
272
|
+
defaults.themeConfig?.codeTheme,
|
|
273
|
+
},
|
|
274
|
+
i18n: userConfig.i18n,
|
|
275
|
+
versions: userConfig.versions,
|
|
276
|
+
siteUrl: userConfig.siteUrl,
|
|
277
|
+
plugins: userConfig.plugins || [],
|
|
278
|
+
external: userConfig.external,
|
|
279
|
+
integrations: userConfig.integrations,
|
|
280
|
+
}
|
|
225
281
|
}
|
package/src/node/index.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
import { boltdocsPlugin } from
|
|
3
|
-
import { boltdocsMdxPlugin } from
|
|
4
|
-
import { BoltdocsPluginOptions } from
|
|
1
|
+
import type { Plugin } from 'vite'
|
|
2
|
+
import { boltdocsPlugin } from './plugin/index'
|
|
3
|
+
import { boltdocsMdxPlugin } from './mdx'
|
|
4
|
+
import type { BoltdocsPluginOptions } from './plugin/index'
|
|
5
5
|
|
|
6
|
-
import { resolveConfig } from
|
|
6
|
+
import { resolveConfig } from './config'
|
|
7
7
|
|
|
8
8
|
export default async function boltdocs(
|
|
9
9
|
options?: BoltdocsPluginOptions,
|
|
10
10
|
): Promise<Plugin[]> {
|
|
11
|
-
const docsDir = options?.docsDir ||
|
|
12
|
-
const config = await resolveConfig(docsDir)
|
|
11
|
+
const docsDir = options?.docsDir || 'docs'
|
|
12
|
+
const config = await resolveConfig(docsDir)
|
|
13
13
|
|
|
14
|
-
return [...boltdocsPlugin(options, config), boltdocsMdxPlugin(config)]
|
|
14
|
+
return [...boltdocsPlugin(options, config), boltdocsMdxPlugin(config)]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export type { BoltdocsPluginOptions }
|
|
18
|
-
export { generateStaticPages } from
|
|
19
|
-
export type { SSGOptions } from
|
|
20
|
-
export type { RouteMeta } from
|
|
21
|
-
export type { BoltdocsConfig, BoltdocsThemeConfig } from
|
|
17
|
+
export type { BoltdocsPluginOptions }
|
|
18
|
+
export { generateStaticPages } from './ssg'
|
|
19
|
+
export type { SSGOptions } from './ssg'
|
|
20
|
+
export type { RouteMeta } from './routes'
|
|
21
|
+
export type { BoltdocsConfig, BoltdocsThemeConfig } from './config'
|