boltdocs 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/node/index.js +21 -6
  2. package/dist/node/index.mjs +21 -6
  3. package/package.json +1 -1
  4. package/src/client/app/index.tsx +344 -344
  5. package/src/client/app/preload.tsx +56 -56
  6. package/src/client/index.ts +40 -40
  7. package/src/client/ssr.tsx +51 -51
  8. package/src/client/theme/components/CodeBlock/CodeBlock.tsx +76 -76
  9. package/src/client/theme/components/CodeBlock/index.ts +1 -1
  10. package/src/client/theme/components/PackageManagerTabs/PackageManagerTabs.tsx +154 -154
  11. package/src/client/theme/components/PackageManagerTabs/index.ts +1 -1
  12. package/src/client/theme/components/PackageManagerTabs/pkg-tabs.css +64 -64
  13. package/src/client/theme/components/Playground/Playground.tsx +124 -124
  14. package/src/client/theme/components/Playground/index.ts +1 -1
  15. package/src/client/theme/components/Playground/playground.css +168 -168
  16. package/src/client/theme/components/Video/Video.tsx +84 -84
  17. package/src/client/theme/components/Video/index.ts +1 -1
  18. package/src/client/theme/components/Video/video.css +41 -41
  19. package/src/client/theme/components/mdx/Admonition.tsx +80 -80
  20. package/src/client/theme/components/mdx/Badge.tsx +31 -31
  21. package/src/client/theme/components/mdx/Button.tsx +50 -50
  22. package/src/client/theme/components/mdx/Card.tsx +80 -80
  23. package/src/client/theme/components/mdx/List.tsx +57 -57
  24. package/src/client/theme/components/mdx/Tabs.tsx +94 -94
  25. package/src/client/theme/components/mdx/index.ts +18 -18
  26. package/src/client/theme/components/mdx/mdx-components.css +424 -424
  27. package/src/client/theme/icons/bun.tsx +62 -62
  28. package/src/client/theme/icons/deno.tsx +20 -20
  29. package/src/client/theme/icons/discord.tsx +12 -12
  30. package/src/client/theme/icons/github.tsx +15 -15
  31. package/src/client/theme/icons/npm.tsx +13 -13
  32. package/src/client/theme/icons/pnpm.tsx +72 -72
  33. package/src/client/theme/icons/twitter.tsx +12 -12
  34. package/src/client/theme/styles/markdown.css +343 -343
  35. package/src/client/theme/styles/variables.css +162 -162
  36. package/src/client/theme/styles.css +37 -37
  37. package/src/client/theme/ui/BackgroundGradient/BackgroundGradient.tsx +10 -10
  38. package/src/client/theme/ui/BackgroundGradient/index.ts +1 -1
  39. package/src/client/theme/ui/Breadcrumbs/Breadcrumbs.tsx +68 -68
  40. package/src/client/theme/ui/Breadcrumbs/index.ts +1 -1
  41. package/src/client/theme/ui/Footer/footer.css +32 -32
  42. package/src/client/theme/ui/Head/Head.tsx +69 -69
  43. package/src/client/theme/ui/Head/index.ts +1 -1
  44. package/src/client/theme/ui/LanguageSwitcher/LanguageSwitcher.tsx +125 -125
  45. package/src/client/theme/ui/LanguageSwitcher/index.ts +1 -1
  46. package/src/client/theme/ui/LanguageSwitcher/language-switcher.css +98 -98
  47. package/src/client/theme/ui/Layout/Layout.tsx +202 -202
  48. package/src/client/theme/ui/Layout/base.css +76 -76
  49. package/src/client/theme/ui/Layout/index.ts +2 -2
  50. package/src/client/theme/ui/Layout/pagination.css +72 -72
  51. package/src/client/theme/ui/Layout/responsive.css +36 -36
  52. package/src/client/theme/ui/Link/Link.tsx +254 -254
  53. package/src/client/theme/ui/Link/index.ts +2 -2
  54. package/src/client/theme/ui/Loading/Loading.tsx +10 -10
  55. package/src/client/theme/ui/Loading/index.ts +1 -1
  56. package/src/client/theme/ui/Loading/loading.css +30 -30
  57. package/src/client/theme/ui/Navbar/GithubStars.tsx +27 -27
  58. package/src/client/theme/ui/Navbar/Navbar.tsx +145 -145
  59. package/src/client/theme/ui/Navbar/index.ts +2 -2
  60. package/src/client/theme/ui/Navbar/navbar.css +233 -233
  61. package/src/client/theme/ui/NotFound/NotFound.tsx +19 -19
  62. package/src/client/theme/ui/NotFound/index.ts +1 -1
  63. package/src/client/theme/ui/NotFound/not-found.css +64 -64
  64. package/src/client/theme/ui/OnThisPage/OnThisPage.tsx +235 -235
  65. package/src/client/theme/ui/OnThisPage/index.ts +1 -1
  66. package/src/client/theme/ui/OnThisPage/toc.css +132 -132
  67. package/src/client/theme/ui/PoweredBy/PoweredBy.tsx +18 -18
  68. package/src/client/theme/ui/PoweredBy/index.ts +1 -1
  69. package/src/client/theme/ui/PoweredBy/powered-by.css +76 -76
  70. package/src/client/theme/ui/SearchDialog/SearchDialog.tsx +199 -199
  71. package/src/client/theme/ui/SearchDialog/index.ts +1 -1
  72. package/src/client/theme/ui/SearchDialog/search.css +152 -152
  73. package/src/client/theme/ui/Sidebar/Sidebar.tsx +204 -204
  74. package/src/client/theme/ui/Sidebar/index.ts +1 -1
  75. package/src/client/theme/ui/Sidebar/sidebar.css +236 -236
  76. package/src/client/theme/ui/ThemeToggle/ThemeToggle.tsx +69 -69
  77. package/src/client/theme/ui/ThemeToggle/index.ts +1 -1
  78. package/src/client/theme/ui/VersionSwitcher/VersionSwitcher.tsx +136 -136
  79. package/src/client/theme/ui/VersionSwitcher/index.ts +1 -1
  80. package/src/client/types.ts +50 -50
  81. package/src/client/utils.ts +26 -26
  82. package/src/node/cache.ts +408 -408
  83. package/src/node/config.ts +192 -192
  84. package/src/node/index.ts +21 -21
  85. package/src/node/mdx.ts +120 -120
  86. package/src/node/plugin/entry.ts +58 -58
  87. package/src/node/plugin/html.ts +55 -55
  88. package/src/node/plugin/index.ts +193 -193
  89. package/src/node/plugin/types.ts +11 -11
  90. package/src/node/routes/cache.ts +28 -28
  91. package/src/node/routes/index.ts +167 -167
  92. package/src/node/routes/parser.ts +153 -127
  93. package/src/node/routes/sorter.ts +42 -42
  94. package/src/node/routes/types.ts +49 -49
  95. package/src/node/ssg/index.ts +114 -114
  96. package/src/node/ssg/meta.ts +34 -34
  97. package/src/node/ssg/options.ts +13 -13
  98. package/src/node/ssg/sitemap.ts +54 -54
  99. package/src/node/utils.ts +134 -134
  100. package/tsconfig.json +20 -20
  101. package/tsup.config.ts +22 -22
@@ -1,136 +1,136 @@
1
- import { useState, useRef, useEffect } from "react";
2
- import { Layers, ChevronDown } from "lucide-react";
3
- import { useNavigate, useLocation } from "react-router-dom";
4
- import { BoltdocsVersionsConfig } from "../../../../node/config";
5
- import { ComponentRoute } from "../../../types";
6
-
7
- function getBaseFilePath(
8
- filePath: string,
9
- version: string | undefined,
10
- locale: string | undefined,
11
- ): string {
12
- let path = filePath;
13
- if (version && (path === version || path.startsWith(version + "/"))) {
14
- path = path === version ? "index.md" : path.slice(version.length + 1);
15
- }
16
- if (locale && (path === locale || path.startsWith(locale + "/"))) {
17
- path = path === locale ? "index.md" : path.slice(locale.length + 1);
18
- }
19
- return path;
20
- }
21
-
22
- export function VersionSwitcher({
23
- versions,
24
- currentVersion,
25
- currentLocale,
26
- allRoutes,
27
- }: {
28
- versions: BoltdocsVersionsConfig;
29
- currentVersion: string;
30
- currentLocale?: string;
31
- allRoutes: ComponentRoute[];
32
- }) {
33
- const [isOpen, setIsOpen] = useState(false);
34
- const dropdownRef = useRef<HTMLDivElement>(null);
35
- const navigate = useNavigate();
36
- const location = useLocation();
37
-
38
- useEffect(() => {
39
- function handleClickOutside(event: MouseEvent) {
40
- if (
41
- dropdownRef.current &&
42
- !dropdownRef.current.contains(event.target as Node)
43
- ) {
44
- setIsOpen(false);
45
- }
46
- }
47
- document.addEventListener("mousedown", handleClickOutside);
48
- return () => document.removeEventListener("mousedown", handleClickOutside);
49
- }, []);
50
-
51
- const handleSelect = (version: string) => {
52
- setIsOpen(false);
53
- if (version === currentVersion) return;
54
-
55
- const currentRoute = allRoutes.find((r) => r.path === location.pathname);
56
- let targetPath = `/docs/${version}`; // Default to root of the new version
57
-
58
- if (currentRoute) {
59
- const baseFile = getBaseFilePath(
60
- currentRoute.filePath,
61
- currentRoute.version,
62
- currentRoute.locale,
63
- );
64
-
65
- const targetRoute = allRoutes.find(
66
- (r) =>
67
- getBaseFilePath(r.filePath, r.version, r.locale) === baseFile &&
68
- (r.version || versions.defaultVersion) === version &&
69
- (currentLocale ? r.locale === currentLocale : !r.locale),
70
- );
71
-
72
- if (targetRoute) {
73
- targetPath = targetRoute.path;
74
- } else {
75
- // Fallback to version index
76
- const versionIndexRoute = allRoutes.find(
77
- (r) =>
78
- getBaseFilePath(r.filePath, r.version, r.locale) === "index.md" &&
79
- (r.version || versions.defaultVersion) === version &&
80
- (currentLocale ? r.locale === currentLocale : !r.locale),
81
- );
82
- targetPath = versionIndexRoute
83
- ? versionIndexRoute.path
84
- : `/docs/${version}${currentLocale ? `/${currentLocale}` : ""}`;
85
- }
86
- }
87
-
88
- navigate(targetPath);
89
- };
90
-
91
- return (
92
- <div
93
- className="boltdocs-version-switcher"
94
- ref={dropdownRef}
95
- style={{ position: "relative", display: "flex", alignItems: "center" }}
96
- >
97
- <button
98
- className="navbar-version"
99
- onClick={() => setIsOpen(!isOpen)}
100
- aria-label="Switch version"
101
- aria-expanded={isOpen}
102
- aria-haspopup="listbox"
103
- style={{
104
- fontFamily: "inherit",
105
- padding: "0.25rem 0.5rem",
106
- marginLeft: "0.5rem",
107
- }}
108
- >
109
- <span>{versions.versions[currentVersion] || currentVersion}</span>
110
- <ChevronDown size={14} />
111
- </button>
112
-
113
- {isOpen && (
114
- <div
115
- className="language-dropdown"
116
- style={{
117
- left: "0.5rem",
118
- right: "auto",
119
- minWidth: "150px",
120
- top: "calc(100% + 8px)",
121
- }}
122
- >
123
- {Object.entries(versions.versions).map(([key, label]) => (
124
- <button
125
- key={key}
126
- className={`language-option ${key === currentVersion ? "active" : ""}`}
127
- onClick={() => handleSelect(key)}
128
- >
129
- {label}
130
- </button>
131
- ))}
132
- </div>
133
- )}
134
- </div>
135
- );
136
- }
1
+ import { useState, useRef, useEffect } from "react";
2
+ import { Layers, ChevronDown } from "lucide-react";
3
+ import { useNavigate, useLocation } from "react-router-dom";
4
+ import { BoltdocsVersionsConfig } from "../../../../node/config";
5
+ import { ComponentRoute } from "../../../types";
6
+
7
+ function getBaseFilePath(
8
+ filePath: string,
9
+ version: string | undefined,
10
+ locale: string | undefined,
11
+ ): string {
12
+ let path = filePath;
13
+ if (version && (path === version || path.startsWith(version + "/"))) {
14
+ path = path === version ? "index.md" : path.slice(version.length + 1);
15
+ }
16
+ if (locale && (path === locale || path.startsWith(locale + "/"))) {
17
+ path = path === locale ? "index.md" : path.slice(locale.length + 1);
18
+ }
19
+ return path;
20
+ }
21
+
22
+ export function VersionSwitcher({
23
+ versions,
24
+ currentVersion,
25
+ currentLocale,
26
+ allRoutes,
27
+ }: {
28
+ versions: BoltdocsVersionsConfig;
29
+ currentVersion: string;
30
+ currentLocale?: string;
31
+ allRoutes: ComponentRoute[];
32
+ }) {
33
+ const [isOpen, setIsOpen] = useState(false);
34
+ const dropdownRef = useRef<HTMLDivElement>(null);
35
+ const navigate = useNavigate();
36
+ const location = useLocation();
37
+
38
+ useEffect(() => {
39
+ function handleClickOutside(event: MouseEvent) {
40
+ if (
41
+ dropdownRef.current &&
42
+ !dropdownRef.current.contains(event.target as Node)
43
+ ) {
44
+ setIsOpen(false);
45
+ }
46
+ }
47
+ document.addEventListener("mousedown", handleClickOutside);
48
+ return () => document.removeEventListener("mousedown", handleClickOutside);
49
+ }, []);
50
+
51
+ const handleSelect = (version: string) => {
52
+ setIsOpen(false);
53
+ if (version === currentVersion) return;
54
+
55
+ const currentRoute = allRoutes.find((r) => r.path === location.pathname);
56
+ let targetPath = `/docs/${version}`; // Default to root of the new version
57
+
58
+ if (currentRoute) {
59
+ const baseFile = getBaseFilePath(
60
+ currentRoute.filePath,
61
+ currentRoute.version,
62
+ currentRoute.locale,
63
+ );
64
+
65
+ const targetRoute = allRoutes.find(
66
+ (r) =>
67
+ getBaseFilePath(r.filePath, r.version, r.locale) === baseFile &&
68
+ (r.version || versions.defaultVersion) === version &&
69
+ (currentLocale ? r.locale === currentLocale : !r.locale),
70
+ );
71
+
72
+ if (targetRoute) {
73
+ targetPath = targetRoute.path;
74
+ } else {
75
+ // Fallback to version index
76
+ const versionIndexRoute = allRoutes.find(
77
+ (r) =>
78
+ getBaseFilePath(r.filePath, r.version, r.locale) === "index.md" &&
79
+ (r.version || versions.defaultVersion) === version &&
80
+ (currentLocale ? r.locale === currentLocale : !r.locale),
81
+ );
82
+ targetPath = versionIndexRoute
83
+ ? versionIndexRoute.path
84
+ : `/docs/${version}${currentLocale ? `/${currentLocale}` : ""}`;
85
+ }
86
+ }
87
+
88
+ navigate(targetPath);
89
+ };
90
+
91
+ return (
92
+ <div
93
+ className="boltdocs-version-switcher"
94
+ ref={dropdownRef}
95
+ style={{ position: "relative", display: "flex", alignItems: "center" }}
96
+ >
97
+ <button
98
+ className="navbar-version"
99
+ onClick={() => setIsOpen(!isOpen)}
100
+ aria-label="Switch version"
101
+ aria-expanded={isOpen}
102
+ aria-haspopup="listbox"
103
+ style={{
104
+ fontFamily: "inherit",
105
+ padding: "0.25rem 0.5rem",
106
+ marginLeft: "0.5rem",
107
+ }}
108
+ >
109
+ <span>{versions.versions[currentVersion] || currentVersion}</span>
110
+ <ChevronDown size={14} />
111
+ </button>
112
+
113
+ {isOpen && (
114
+ <div
115
+ className="language-dropdown"
116
+ style={{
117
+ left: "0.5rem",
118
+ right: "auto",
119
+ minWidth: "150px",
120
+ top: "calc(100% + 8px)",
121
+ }}
122
+ >
123
+ {Object.entries(versions.versions).map(([key, label]) => (
124
+ <button
125
+ key={key}
126
+ className={`language-option ${key === currentVersion ? "active" : ""}`}
127
+ onClick={() => handleSelect(key)}
128
+ >
129
+ {label}
130
+ </button>
131
+ ))}
132
+ </div>
133
+ )}
134
+ </div>
135
+ );
136
+ }
@@ -1 +1 @@
1
- export { VersionSwitcher } from "./VersionSwitcher";
1
+ export { VersionSwitcher } from "./VersionSwitcher";
@@ -1,50 +1,50 @@
1
- import React from "react";
2
-
3
- /**
4
- * Metadata provided by the server for a specific route.
5
- * Maps closely to the `RouteMeta` type in the Node environment.
6
- */
7
- export interface ComponentRoute {
8
- /** The final URL path */
9
- path: string;
10
- /** The absolute filesystem path of the source file */
11
- componentPath: string;
12
- /** The page title */
13
- title: string;
14
- /** Explicit order in the sidebar */
15
- sidebarPosition?: number;
16
- /** The relative path from the docs directory */
17
- filePath: string;
18
- /** The group directory name */
19
- group?: string;
20
- /** The display title of the group */
21
- groupTitle?: string;
22
- /** Explicit order of the group in the sidebar */
23
- groupPosition?: number;
24
- /** Extracted markdown headings for search indexing */
25
- headings?: { level: number; text: string; id: string }[];
26
- /** The locale this route belongs to, if i18n is configured */
27
- locale?: string;
28
- /** The version this route belongs to, if versioning is configured */
29
- version?: string;
30
- }
31
-
32
- /**
33
- * Configuration options for initializing the Boltdocs client app.
34
- */
35
- export interface CreateBoltdocsAppOptions {
36
- /** CSS selector for the DOM element where the app should mount (e.g. '#root') */
37
- target: string;
38
- /** Initial routes generated by the Vite plugin (`virtual:boltdocs-routes`) */
39
- routes: ComponentRoute[];
40
- /** Site configuration (`virtual:boltdocs-config`) */
41
- config: any;
42
- /** Dynamic import mapping from `import.meta.glob` for the documentation pages */
43
- modules: Record<string, () => Promise<any>>;
44
- /** The `import.meta.hot` instance necessary for fast refresh/HMR updates */
45
- hot?: any;
46
- /** Optional custom React component to render when visiting the root path ('/') */
47
- homePage?: React.ComponentType;
48
- /** Optional custom MDX components provided by plugins */
49
- components?: Record<string, React.ComponentType<any>>;
50
- }
1
+ import React from "react";
2
+
3
+ /**
4
+ * Metadata provided by the server for a specific route.
5
+ * Maps closely to the `RouteMeta` type in the Node environment.
6
+ */
7
+ export interface ComponentRoute {
8
+ /** The final URL path */
9
+ path: string;
10
+ /** The absolute filesystem path of the source file */
11
+ componentPath: string;
12
+ /** The page title */
13
+ title: string;
14
+ /** Explicit order in the sidebar */
15
+ sidebarPosition?: number;
16
+ /** The relative path from the docs directory */
17
+ filePath: string;
18
+ /** The group directory name */
19
+ group?: string;
20
+ /** The display title of the group */
21
+ groupTitle?: string;
22
+ /** Explicit order of the group in the sidebar */
23
+ groupPosition?: number;
24
+ /** Extracted markdown headings for search indexing */
25
+ headings?: { level: number; text: string; id: string }[];
26
+ /** The locale this route belongs to, if i18n is configured */
27
+ locale?: string;
28
+ /** The version this route belongs to, if versioning is configured */
29
+ version?: string;
30
+ }
31
+
32
+ /**
33
+ * Configuration options for initializing the Boltdocs client app.
34
+ */
35
+ export interface CreateBoltdocsAppOptions {
36
+ /** CSS selector for the DOM element where the app should mount (e.g. '#root') */
37
+ target: string;
38
+ /** Initial routes generated by the Vite plugin (`virtual:boltdocs-routes`) */
39
+ routes: ComponentRoute[];
40
+ /** Site configuration (`virtual:boltdocs-config`) */
41
+ config: any;
42
+ /** Dynamic import mapping from `import.meta.glob` for the documentation pages */
43
+ modules: Record<string, () => Promise<any>>;
44
+ /** The `import.meta.hot` instance necessary for fast refresh/HMR updates */
45
+ hot?: any;
46
+ /** Optional custom React component to render when visiting the root path ('/') */
47
+ homePage?: React.ComponentType;
48
+ /** Optional custom MDX components provided by plugins */
49
+ components?: Record<string, React.ComponentType<any>>;
50
+ }
@@ -1,26 +1,26 @@
1
- /**
2
- * Get the number of stars for a GitHub repository.
3
- * @param repo - The repository name in the format "owner/repo".
4
- * @returns The number of stars for the repository.
5
- */
6
- export async function getStarsRepo(repo: string) {
7
- const response = await fetch(`https://api.github.com/repos/${repo}`);
8
- const data = await response.json();
9
- if (data.stargazers_count !== undefined) {
10
- return formatStars(data.stargazers_count);
11
- } else {
12
- return "0"; // Fallback
13
- }
14
- }
15
-
16
- /**
17
- * Format a number of stars in a compact form.
18
- * @param count - The number of stars to format.
19
- * @returns The formatted number of stars.
20
- */
21
- const formatStars = (count: number): string => {
22
- return Intl.NumberFormat("en", {
23
- notation: "compact",
24
- compactDisplay: "short",
25
- }).format(count);
26
- };
1
+ /**
2
+ * Get the number of stars for a GitHub repository.
3
+ * @param repo - The repository name in the format "owner/repo".
4
+ * @returns The number of stars for the repository.
5
+ */
6
+ export async function getStarsRepo(repo: string) {
7
+ const response = await fetch(`https://api.github.com/repos/${repo}`);
8
+ const data = await response.json();
9
+ if (data.stargazers_count !== undefined) {
10
+ return formatStars(data.stargazers_count);
11
+ } else {
12
+ return "0"; // Fallback
13
+ }
14
+ }
15
+
16
+ /**
17
+ * Format a number of stars in a compact form.
18
+ * @param count - The number of stars to format.
19
+ * @returns The formatted number of stars.
20
+ */
21
+ const formatStars = (count: number): string => {
22
+ return Intl.NumberFormat("en", {
23
+ notation: "compact",
24
+ compactDisplay: "short",
25
+ }).format(count);
26
+ };