boltdocs 1.10.2 → 1.11.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/package.json +29 -7
- package/src/client/app/config-context.tsx +18 -0
- package/src/client/app/docs-layout.tsx +14 -0
- package/src/client/app/index.tsx +132 -260
- 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 -83
- 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 +106 -81
- package/src/node/routes/sorter.ts +15 -15
- package/src/node/routes/types.ts +24 -24
- package/src/node/ssg/index.ts +46 -46
- 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 +31 -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/index.d.mts +0 -372
- package/dist/client/index.d.ts +0 -372
- package/dist/client/index.js +0 -3630
- package/dist/client/index.mjs +0 -697
- package/dist/client/ssr.css +0 -2847
- package/dist/client/ssr.d.mts +0 -27
- package/dist/client/ssr.d.ts +0 -27
- package/dist/client/ssr.js +0 -2928
- package/dist/client/ssr.mjs +0 -33
- package/dist/config-BsFQ-ErD.d.mts +0 -159
- package/dist/config-BsFQ-ErD.d.ts +0 -159
- package/dist/node/index.d.mts +0 -91
- package/dist/node/index.d.ts +0 -91
- package/dist/node/index.js +0 -1187
- package/dist/node/index.mjs +0 -762
- 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/ssg/sitemap.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BoltdocsConfig } from
|
|
2
|
-
import { escapeXml } from
|
|
1
|
+
import type { BoltdocsConfig } from '../config'
|
|
2
|
+
import { escapeXml } from '../utils'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Generates a standard XML sitemap for search engine crawlers.
|
|
@@ -12,20 +12,20 @@ export function generateSitemap(
|
|
|
12
12
|
routePaths: string[],
|
|
13
13
|
config?: BoltdocsConfig,
|
|
14
14
|
): string {
|
|
15
|
-
const baseUrl = config?.siteUrl?.replace(/\/$/,
|
|
16
|
-
const today = new Date().toISOString().split(
|
|
15
|
+
const baseUrl = config?.siteUrl?.replace(/\/$/, '') || 'https://example.com'
|
|
16
|
+
const today = new Date().toISOString().split('T')[0]
|
|
17
17
|
|
|
18
|
-
const rootEntries = [{ url:
|
|
18
|
+
const rootEntries = [{ url: '/', priority: '1.0', changefreq: 'daily' }]
|
|
19
19
|
|
|
20
20
|
if (config?.i18n) {
|
|
21
|
-
const defaultLocale = config.i18n.defaultLocale
|
|
21
|
+
const defaultLocale = config.i18n.defaultLocale
|
|
22
22
|
for (const locale of Object.keys(config.i18n.locales)) {
|
|
23
23
|
if (locale !== defaultLocale) {
|
|
24
24
|
rootEntries.push({
|
|
25
25
|
url: `/${locale}/`,
|
|
26
|
-
priority:
|
|
27
|
-
changefreq:
|
|
28
|
-
})
|
|
26
|
+
priority: '1.0',
|
|
27
|
+
changefreq: 'daily',
|
|
28
|
+
})
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -34,10 +34,10 @@ export function generateSitemap(
|
|
|
34
34
|
...rootEntries,
|
|
35
35
|
...routePaths.map((p) => ({
|
|
36
36
|
url: p,
|
|
37
|
-
priority:
|
|
38
|
-
changefreq:
|
|
37
|
+
priority: '0.8',
|
|
38
|
+
changefreq: 'weekly',
|
|
39
39
|
})),
|
|
40
|
-
]
|
|
40
|
+
]
|
|
41
41
|
|
|
42
42
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
43
43
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
@@ -50,6 +50,6 @@ ${entries
|
|
|
50
50
|
<priority>${e.priority}</priority>
|
|
51
51
|
</url>`,
|
|
52
52
|
)
|
|
53
|
-
.join(
|
|
54
|
-
</urlset
|
|
53
|
+
.join('\n')}
|
|
54
|
+
</urlset>`
|
|
55
55
|
}
|
package/src/node/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import matter from
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import matter from 'gray-matter'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Normalizes a file path by replacing Windows backslashes with forward slashes.
|
|
@@ -9,7 +9,7 @@ import matter from "gray-matter";
|
|
|
9
9
|
* @returns The normalized path using forward slashes
|
|
10
10
|
*/
|
|
11
11
|
export function normalizePath(p: string): string {
|
|
12
|
-
return p.replace(/\\/g,
|
|
12
|
+
return p.replace(/\\/g, '/')
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -19,7 +19,7 @@ export function normalizePath(p: string): string {
|
|
|
19
19
|
* @returns The name without the numeric prefix
|
|
20
20
|
*/
|
|
21
21
|
export function stripNumberPrefix(name: string): string {
|
|
22
|
-
return name.replace(/^\d+\./,
|
|
22
|
+
return name.replace(/^\d+\./, '')
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -29,8 +29,8 @@ export function stripNumberPrefix(name: string): string {
|
|
|
29
29
|
* @returns The extracted number, or undefined if none exists
|
|
30
30
|
*/
|
|
31
31
|
export function extractNumberPrefix(name: string): number | undefined {
|
|
32
|
-
const match = name.match(/^(\d+)\./)
|
|
33
|
-
return match ? parseInt(match[1], 10) : undefined
|
|
32
|
+
const match = name.match(/^(\d+)\./)
|
|
33
|
+
return match ? parseInt(match[1], 10) : undefined
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -40,7 +40,7 @@ export function extractNumberPrefix(name: string): number | undefined {
|
|
|
40
40
|
* @returns True if the file ends with .md or .mdx, false otherwise
|
|
41
41
|
*/
|
|
42
42
|
export function isDocFile(filePath: string): boolean {
|
|
43
|
-
return /\.mdx?$/.test(filePath)
|
|
43
|
+
return /\.mdx?$/.test(filePath)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -53,9 +53,9 @@ export function isDocFile(filePath: string): boolean {
|
|
|
53
53
|
*/
|
|
54
54
|
export function getFileMtime(filePath: string): number {
|
|
55
55
|
try {
|
|
56
|
-
return fs.statSync(filePath).mtimeMs
|
|
56
|
+
return fs.statSync(filePath).mtimeMs
|
|
57
57
|
} catch {
|
|
58
|
-
return 0
|
|
58
|
+
return 0
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -67,12 +67,12 @@ export function getFileMtime(filePath: string): number {
|
|
|
67
67
|
* @returns An object containing the parsed metadata (`data`) and the raw markdown (`content`)
|
|
68
68
|
*/
|
|
69
69
|
export function parseFrontmatter(filePath: string): {
|
|
70
|
-
data: Record<string, any
|
|
71
|
-
content: string
|
|
70
|
+
data: Record<string, any>
|
|
71
|
+
content: string
|
|
72
72
|
} {
|
|
73
|
-
const raw = fs.readFileSync(filePath,
|
|
74
|
-
const { data, content } = matter(raw)
|
|
75
|
-
return { data, content }
|
|
73
|
+
const raw = fs.readFileSync(filePath, 'utf-8')
|
|
74
|
+
const { data, content } = matter(raw)
|
|
75
|
+
return { data, content }
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
@@ -84,11 +84,11 @@ export function parseFrontmatter(filePath: string): {
|
|
|
84
84
|
*/
|
|
85
85
|
export function escapeHtml(str: string): string {
|
|
86
86
|
return str
|
|
87
|
-
.replace(/&/g,
|
|
88
|
-
.replace(/"/g,
|
|
89
|
-
.replace(/'/g,
|
|
90
|
-
.replace(/</g,
|
|
91
|
-
.replace(/>/g,
|
|
87
|
+
.replace(/&/g, '&')
|
|
88
|
+
.replace(/"/g, '"')
|
|
89
|
+
.replace(/'/g, ''')
|
|
90
|
+
.replace(/</g, '<')
|
|
91
|
+
.replace(/>/g, '>')
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -98,7 +98,7 @@ export function escapeHtml(str: string): string {
|
|
|
98
98
|
* @returns The escaped string
|
|
99
99
|
*/
|
|
100
100
|
export function escapeXml(str: string): string {
|
|
101
|
-
return escapeHtml(str)
|
|
101
|
+
return escapeHtml(str)
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
@@ -111,29 +111,29 @@ export function escapeXml(str: string): string {
|
|
|
111
111
|
*/
|
|
112
112
|
export function fileToRoutePath(relativePath: string): string {
|
|
113
113
|
// Strip number prefixes from every segment
|
|
114
|
-
let cleanedPath = relativePath.split(
|
|
114
|
+
let cleanedPath = relativePath.split('/').map(stripNumberPrefix).join('/')
|
|
115
115
|
|
|
116
116
|
// Remove trailing slash if present
|
|
117
|
-
let routePath = cleanedPath.replace(/\/$/,
|
|
117
|
+
let routePath = cleanedPath.replace(/\/$/, '')
|
|
118
118
|
|
|
119
|
-
routePath = routePath.replace(/\.mdx?$/,
|
|
119
|
+
routePath = routePath.replace(/\.mdx?$/, '')
|
|
120
120
|
|
|
121
121
|
// Handle index files → directory root
|
|
122
|
-
if (routePath ===
|
|
123
|
-
routePath = routePath.replace(/index$/,
|
|
122
|
+
if (routePath === 'index' || routePath.endsWith('/index')) {
|
|
123
|
+
routePath = routePath.replace(/index$/, '')
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// Ensure leading slash
|
|
127
|
-
if (!routePath.startsWith(
|
|
128
|
-
routePath =
|
|
127
|
+
if (!routePath.startsWith('/')) {
|
|
128
|
+
routePath = '/' + routePath
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// Remove trailing slash (except for root '/')
|
|
132
|
-
if (routePath.length > 1 && routePath.endsWith(
|
|
133
|
-
routePath = routePath.slice(0, -1)
|
|
132
|
+
if (routePath.length > 1 && routePath.endsWith('/')) {
|
|
133
|
+
routePath = routePath.slice(0, -1)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
return routePath
|
|
136
|
+
return routePath
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -144,5 +144,5 @@ export function fileToRoutePath(relativePath: string): string {
|
|
|
144
144
|
* @returns The capitalized string
|
|
145
145
|
*/
|
|
146
146
|
export function capitalize(str: string): string {
|
|
147
|
-
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
147
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
148
148
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"jsx": "react-jsx",
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"outDir": "dist",
|
|
12
|
+
"baseUrl": ".",
|
|
13
|
+
"paths": {
|
|
14
|
+
"@/*": ["src/*"],
|
|
15
|
+
"@client/*": ["src/client/*"],
|
|
16
|
+
"@node/*": ["src/node/*"],
|
|
17
|
+
"@theme/*": ["src/client/theme/*"],
|
|
18
|
+
"@components/*": ["src/client/components/*"],
|
|
19
|
+
"@integrations/*": ["src/client/integrations/*"],
|
|
20
|
+
"@hooks/*": ["src/client/hooks/*"],
|
|
21
|
+
"@primitives/*": ["src/client/components/primitives/*"]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"include": ["src"],
|
|
25
|
+
"exclude": ["node_modules", "dist", "src/node/cli"]
|
|
26
|
+
}
|
package/tsup.config.ts
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
4
|
entry: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
'src/node/index.ts',
|
|
6
|
+
'src/client/index.ts',
|
|
7
|
+
'src/client/ssr.tsx',
|
|
8
|
+
'src/client/hooks/index.ts',
|
|
9
|
+
'src/client/components/mdx/index.ts',
|
|
9
10
|
],
|
|
10
|
-
format: [
|
|
11
|
+
format: ['cjs', 'esm'],
|
|
11
12
|
dts: true,
|
|
12
|
-
tsconfig:
|
|
13
|
+
tsconfig: './tsconfig.json',
|
|
13
14
|
clean: true,
|
|
15
|
+
minify: true,
|
|
16
|
+
minifySyntax: true,
|
|
17
|
+
minifyWhitespace: true,
|
|
18
|
+
minifyIdentifiers: true,
|
|
19
|
+
shims: true,
|
|
14
20
|
external: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
'vite',
|
|
22
|
+
'react',
|
|
23
|
+
'react-dom',
|
|
24
|
+
'react-router-dom',
|
|
25
|
+
'virtual:boltdocs-routes',
|
|
26
|
+
'virtual:boltdocs-config',
|
|
27
|
+
'virtual:boltdocs-layout',
|
|
28
|
+
'virtual:boltdocs-mdx-components',
|
|
29
|
+
'virtual:boltdocs-entry',
|
|
21
30
|
],
|
|
22
|
-
})
|
|
31
|
+
})
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Bun,
|
|
3
|
-
Deno,
|
|
4
|
-
NPM,
|
|
5
|
-
Pnpm
|
|
6
|
-
} from "./chunk-7SFUJWTB.mjs";
|
|
7
|
-
import {
|
|
8
|
-
copyToClipboard
|
|
9
|
-
} from "./chunk-FMTOYQLO.mjs";
|
|
10
|
-
|
|
11
|
-
// src/client/theme/components/PackageManagerTabs/PackageManagerTabs.tsx
|
|
12
|
-
import { useState, useCallback } from "react";
|
|
13
|
-
import { Copy, Check } from "lucide-react";
|
|
14
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
var MANAGERS = [
|
|
16
|
-
{ id: "npm", label: "npm", icon: NPM },
|
|
17
|
-
{ id: "pnpm", label: "pnpm", icon: Pnpm },
|
|
18
|
-
{ id: "bun", label: "bun", icon: Bun },
|
|
19
|
-
{ id: "deno", label: "deno", icon: Deno }
|
|
20
|
-
];
|
|
21
|
-
function getCommandForManager(manager, command, pkg) {
|
|
22
|
-
const isInstall = command === "install" || command === "add" || command === "i";
|
|
23
|
-
const isCreate = command === "create" || command === "init";
|
|
24
|
-
const isRun = command === "run" || command === "exec";
|
|
25
|
-
if (isInstall) {
|
|
26
|
-
const pkgArgs2 = pkg ? ` ${pkg}` : "";
|
|
27
|
-
if (manager === "npm") return `npm install${pkgArgs2}`;
|
|
28
|
-
if (manager === "pnpm") return pkg ? `pnpm add${pkgArgs2}` : `pnpm install`;
|
|
29
|
-
if (manager === "bun") return pkg ? `bun add${pkgArgs2}` : `bun install`;
|
|
30
|
-
if (manager === "deno")
|
|
31
|
-
return pkg ? `deno install npm:${pkg}` : `deno install`;
|
|
32
|
-
}
|
|
33
|
-
if (isCreate) {
|
|
34
|
-
const pkgArgs2 = pkg ? ` ${pkg}` : "";
|
|
35
|
-
if (manager === "npm") return `npm create${pkgArgs2}`;
|
|
36
|
-
if (manager === "pnpm") return `pnpm create${pkgArgs2}`;
|
|
37
|
-
if (manager === "bun") return `bun create${pkgArgs2}`;
|
|
38
|
-
if (manager === "deno") return `deno run -A npm:create-${pkg}`;
|
|
39
|
-
}
|
|
40
|
-
if (isRun) {
|
|
41
|
-
const pkgArgs2 = pkg ? ` ${pkg}` : "";
|
|
42
|
-
if (manager === "npm") return `npm run${pkgArgs2}`;
|
|
43
|
-
if (manager === "pnpm") return `pnpm run${pkgArgs2}`;
|
|
44
|
-
if (manager === "bun") return `bun run${pkgArgs2}`;
|
|
45
|
-
if (manager === "deno") return `deno task ${pkg}`;
|
|
46
|
-
}
|
|
47
|
-
const pkgArgs = pkg ? ` ${pkg}` : "";
|
|
48
|
-
return `${manager} ${command}${pkgArgs}`;
|
|
49
|
-
}
|
|
50
|
-
function PackageManagerTabs({
|
|
51
|
-
command,
|
|
52
|
-
pkg = "",
|
|
53
|
-
className = ""
|
|
54
|
-
}) {
|
|
55
|
-
const [activeTab, setActiveTab] = useState("npm");
|
|
56
|
-
const [copied, setCopied] = useState(false);
|
|
57
|
-
const activeCommand = getCommandForManager(activeTab, command, pkg);
|
|
58
|
-
const handleCopy = useCallback(async () => {
|
|
59
|
-
copyToClipboard(activeCommand);
|
|
60
|
-
setCopied(true);
|
|
61
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
62
|
-
}, [activeCommand]);
|
|
63
|
-
return /* @__PURE__ */ jsxs("div", { className: `pkg-tabs-wrapper ${className}`, children: [
|
|
64
|
-
/* @__PURE__ */ jsx("div", { className: "pkg-tabs-header", children: MANAGERS.map((mgr) => {
|
|
65
|
-
const Icon = mgr.icon;
|
|
66
|
-
const isActive = activeTab === mgr.id;
|
|
67
|
-
return /* @__PURE__ */ jsxs(
|
|
68
|
-
"button",
|
|
69
|
-
{
|
|
70
|
-
className: `pkg-tab-btn ${isActive ? "active" : ""}`,
|
|
71
|
-
onClick: () => setActiveTab(mgr.id),
|
|
72
|
-
"aria-selected": isActive,
|
|
73
|
-
role: "tab",
|
|
74
|
-
children: [
|
|
75
|
-
/* @__PURE__ */ jsx(Icon, { className: "pkg-tab-icon", width: "16", height: "16" }),
|
|
76
|
-
/* @__PURE__ */ jsx("span", { children: mgr.label })
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
mgr.id
|
|
80
|
-
);
|
|
81
|
-
}) }),
|
|
82
|
-
/* @__PURE__ */ jsxs("div", { className: "code-block-wrapper pkg-tabs-content", children: [
|
|
83
|
-
/* @__PURE__ */ jsx(
|
|
84
|
-
"button",
|
|
85
|
-
{
|
|
86
|
-
className: `code-block-copy ${copied ? "copied" : ""}`,
|
|
87
|
-
onClick: handleCopy,
|
|
88
|
-
type: "button",
|
|
89
|
-
"aria-label": "Copy code",
|
|
90
|
-
children: copied ? /* @__PURE__ */ jsx(Check, { size: 14 }) : /* @__PURE__ */ jsx(Copy, { size: 14 })
|
|
91
|
-
}
|
|
92
|
-
),
|
|
93
|
-
/* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: /* @__PURE__ */ jsx("span", { className: "line", children: activeCommand }) }) })
|
|
94
|
-
] })
|
|
95
|
-
] });
|
|
96
|
-
}
|
|
97
|
-
export {
|
|
98
|
-
PackageManagerTabs
|
|
99
|
-
};
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Link
|
|
3
|
-
} from "./chunk-TKLQWU7H.mjs";
|
|
4
|
-
import "./chunk-FMTOYQLO.mjs";
|
|
5
|
-
|
|
6
|
-
// src/client/theme/ui/SearchDialog/SearchDialog.tsx
|
|
7
|
-
import React, { useState, useEffect, useRef } from "react";
|
|
8
|
-
import { createPortal } from "react-dom";
|
|
9
|
-
import { Search } from "lucide-react";
|
|
10
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
function SearchDialog({ routes }) {
|
|
12
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
13
|
-
const [query, setQuery] = useState("");
|
|
14
|
-
const inputRef = useRef(null);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const handleKeyDown = (e) => {
|
|
17
|
-
if ((e.metaKey || e.ctrlKey) && e.key === "k") {
|
|
18
|
-
e.preventDefault();
|
|
19
|
-
setIsOpen((prev) => !prev);
|
|
20
|
-
}
|
|
21
|
-
if (e.key === "Escape" && isOpen) {
|
|
22
|
-
setIsOpen(false);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
26
|
-
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
27
|
-
}, [isOpen]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (isOpen) {
|
|
30
|
-
setTimeout(() => inputRef.current?.focus(), 50);
|
|
31
|
-
} else {
|
|
32
|
-
setQuery("");
|
|
33
|
-
}
|
|
34
|
-
}, [isOpen]);
|
|
35
|
-
const searchResults = React.useMemo(() => {
|
|
36
|
-
if (!query) {
|
|
37
|
-
return routes.slice(0, 10).map((r) => ({
|
|
38
|
-
title: r.title,
|
|
39
|
-
path: r.path,
|
|
40
|
-
groupTitle: r.groupTitle
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
const results = [];
|
|
44
|
-
const lowerQuery = query.toLowerCase();
|
|
45
|
-
for (const route of routes) {
|
|
46
|
-
if (route.title && route.title.toLowerCase().includes(lowerQuery)) {
|
|
47
|
-
results.push({
|
|
48
|
-
title: route.title,
|
|
49
|
-
path: route.path,
|
|
50
|
-
groupTitle: route.groupTitle
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (route.headings) {
|
|
54
|
-
for (const heading of route.headings) {
|
|
55
|
-
if (heading.text.toLowerCase().includes(lowerQuery)) {
|
|
56
|
-
results.push({
|
|
57
|
-
title: heading.text,
|
|
58
|
-
path: `${route.path}#${heading.id}`,
|
|
59
|
-
groupTitle: route.title,
|
|
60
|
-
isHeading: true
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (route._content && route._content.toLowerCase().includes(lowerQuery)) {
|
|
66
|
-
results.push({
|
|
67
|
-
title: route.title,
|
|
68
|
-
path: route.path,
|
|
69
|
-
groupTitle: route.groupTitle
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const uniqueResults = [];
|
|
74
|
-
const seenPaths = /* @__PURE__ */ new Set();
|
|
75
|
-
for (const res of results) {
|
|
76
|
-
if (!seenPaths.has(res.path)) {
|
|
77
|
-
seenPaths.add(res.path);
|
|
78
|
-
uniqueResults.push(res);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return uniqueResults.slice(0, 10);
|
|
82
|
-
}, [routes, query]);
|
|
83
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
84
|
-
/* @__PURE__ */ jsxs(
|
|
85
|
-
"div",
|
|
86
|
-
{
|
|
87
|
-
className: "navbar-search",
|
|
88
|
-
role: "button",
|
|
89
|
-
tabIndex: 0,
|
|
90
|
-
onClick: () => setIsOpen(true),
|
|
91
|
-
onKeyDown: (e) => {
|
|
92
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
93
|
-
e.preventDefault();
|
|
94
|
-
setIsOpen(true);
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
"aria-label": "Open search dialog",
|
|
98
|
-
children: [
|
|
99
|
-
/* @__PURE__ */ jsx(Search, { className: "boltdocs-search-icon", size: 18 }),
|
|
100
|
-
"Search docs...",
|
|
101
|
-
/* @__PURE__ */ jsx("kbd", { children: "\u2318K" })
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
),
|
|
105
|
-
isOpen && createPortal(
|
|
106
|
-
/* @__PURE__ */ jsx(
|
|
107
|
-
"div",
|
|
108
|
-
{
|
|
109
|
-
className: "boltdocs-search-overlay",
|
|
110
|
-
onPointerDown: () => setIsOpen(false),
|
|
111
|
-
children: /* @__PURE__ */ jsxs(
|
|
112
|
-
"div",
|
|
113
|
-
{
|
|
114
|
-
className: "boltdocs-search-modal",
|
|
115
|
-
role: "dialog",
|
|
116
|
-
"aria-modal": "true",
|
|
117
|
-
"aria-label": "Search",
|
|
118
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
119
|
-
children: [
|
|
120
|
-
/* @__PURE__ */ jsxs("div", { className: "boltdocs-search-header", children: [
|
|
121
|
-
/* @__PURE__ */ jsx(Search, { size: 18 }),
|
|
122
|
-
/* @__PURE__ */ jsx(
|
|
123
|
-
"input",
|
|
124
|
-
{
|
|
125
|
-
ref: inputRef,
|
|
126
|
-
type: "text",
|
|
127
|
-
"aria-label": "Search documentation input",
|
|
128
|
-
placeholder: "Search documentation...",
|
|
129
|
-
value: query,
|
|
130
|
-
onChange: (e) => setQuery(e.target.value)
|
|
131
|
-
}
|
|
132
|
-
),
|
|
133
|
-
/* @__PURE__ */ jsx(
|
|
134
|
-
"button",
|
|
135
|
-
{
|
|
136
|
-
className: "boltdocs-search-close",
|
|
137
|
-
onClick: () => setIsOpen(false),
|
|
138
|
-
"aria-label": "Close search",
|
|
139
|
-
children: "ESC"
|
|
140
|
-
}
|
|
141
|
-
)
|
|
142
|
-
] }),
|
|
143
|
-
/* @__PURE__ */ jsx("div", { className: "boltdocs-search-results", children: searchResults.length > 0 ? searchResults.map((result) => /* @__PURE__ */ jsxs(
|
|
144
|
-
Link,
|
|
145
|
-
{
|
|
146
|
-
to: result.path === "" ? "/" : result.path,
|
|
147
|
-
className: `boltdocs-search-result-item ${result.isHeading ? "is-heading" : ""}`,
|
|
148
|
-
onClick: (e) => {
|
|
149
|
-
const isSamePath = result.path.split("#")[0] === window.location.pathname;
|
|
150
|
-
if (isSamePath && result.isHeading) {
|
|
151
|
-
e.preventDefault();
|
|
152
|
-
const id = result.path.split("#")[1];
|
|
153
|
-
const el = document.getElementById(id);
|
|
154
|
-
if (el) {
|
|
155
|
-
const offset = 80;
|
|
156
|
-
const bodyRect = document.body.getBoundingClientRect().top;
|
|
157
|
-
const elementRect = el.getBoundingClientRect().top;
|
|
158
|
-
const elementPosition = elementRect - bodyRect;
|
|
159
|
-
const offsetPosition = elementPosition - offset;
|
|
160
|
-
window.scrollTo({
|
|
161
|
-
top: offsetPosition,
|
|
162
|
-
behavior: "smooth"
|
|
163
|
-
});
|
|
164
|
-
window.history.pushState(null, "", `#${id}`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
setIsOpen(false);
|
|
168
|
-
},
|
|
169
|
-
children: [
|
|
170
|
-
/* @__PURE__ */ jsxs("span", { className: "boltdocs-search-result-title", children: [
|
|
171
|
-
result.isHeading ? /* @__PURE__ */ jsx("span", { className: "heading-indicator", children: "#" }) : null,
|
|
172
|
-
result.title
|
|
173
|
-
] }),
|
|
174
|
-
result.groupTitle && /* @__PURE__ */ jsx("span", { className: "boltdocs-search-result-group", children: result.groupTitle })
|
|
175
|
-
]
|
|
176
|
-
},
|
|
177
|
-
result.path
|
|
178
|
-
)) : /* @__PURE__ */ jsxs("div", { className: "boltdocs-search-empty", children: [
|
|
179
|
-
'No results found for "',
|
|
180
|
-
query,
|
|
181
|
-
'"'
|
|
182
|
-
] }) })
|
|
183
|
-
]
|
|
184
|
-
}
|
|
185
|
-
)
|
|
186
|
-
}
|
|
187
|
-
),
|
|
188
|
-
document.body
|
|
189
|
-
)
|
|
190
|
-
] });
|
|
191
|
-
}
|
|
192
|
-
export {
|
|
193
|
-
SearchDialog
|
|
194
|
-
};
|