boltdocs 1.0.4 → 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 (121) hide show
  1. package/dist/{SearchDialog-R36WKAQ7.mjs → SearchDialog-5EDRACEG.mjs} +1 -1
  2. package/dist/{SearchDialog-PYF3QMYG.css → SearchDialog-X57WPTNN.css} +54 -126
  3. package/dist/cache-EHR7SXRU.mjs +12 -0
  4. package/dist/chunk-GSYECEZY.mjs +381 -0
  5. package/dist/{chunk-TWSRXUFF.mjs → chunk-NS7WHDYA.mjs} +229 -418
  6. package/dist/client/index.css +54 -126
  7. package/dist/client/index.d.mts +5 -4
  8. package/dist/client/index.d.ts +5 -4
  9. package/dist/client/index.js +555 -580
  10. package/dist/client/index.mjs +304 -16
  11. package/dist/client/ssr.css +54 -126
  12. package/dist/client/ssr.js +257 -580
  13. package/dist/client/ssr.mjs +1 -1
  14. package/dist/{config-D2XmHJYe.d.mts → config-BD5ZHz15.d.mts} +7 -0
  15. package/dist/{config-D2XmHJYe.d.ts → config-BD5ZHz15.d.ts} +7 -0
  16. package/dist/node/index.d.mts +2 -2
  17. package/dist/node/index.d.ts +2 -2
  18. package/dist/node/index.js +477 -123
  19. package/dist/node/index.mjs +114 -142
  20. package/package.json +2 -2
  21. package/src/client/app/index.tsx +344 -373
  22. package/src/client/app/preload.tsx +56 -56
  23. package/src/client/index.ts +40 -40
  24. package/src/client/ssr.tsx +51 -51
  25. package/src/client/theme/components/CodeBlock/CodeBlock.tsx +76 -76
  26. package/src/client/theme/components/CodeBlock/index.ts +1 -1
  27. package/src/client/theme/components/PackageManagerTabs/PackageManagerTabs.tsx +154 -154
  28. package/src/client/theme/components/PackageManagerTabs/index.ts +1 -1
  29. package/src/client/theme/components/PackageManagerTabs/pkg-tabs.css +64 -64
  30. package/src/client/theme/components/Playground/Playground.tsx +124 -124
  31. package/src/client/theme/components/Playground/index.ts +1 -1
  32. package/src/client/theme/components/Playground/playground.css +168 -168
  33. package/src/client/theme/components/Video/Video.tsx +84 -84
  34. package/src/client/theme/components/Video/index.ts +1 -1
  35. package/src/client/theme/components/Video/video.css +41 -41
  36. package/src/client/theme/components/mdx/Admonition.tsx +80 -80
  37. package/src/client/theme/components/mdx/Badge.tsx +31 -31
  38. package/src/client/theme/components/mdx/Button.tsx +50 -50
  39. package/src/client/theme/components/mdx/Card.tsx +80 -80
  40. package/src/client/theme/components/mdx/List.tsx +57 -57
  41. package/src/client/theme/components/mdx/Tabs.tsx +94 -94
  42. package/src/client/theme/components/mdx/index.ts +18 -18
  43. package/src/client/theme/components/mdx/mdx-components.css +424 -405
  44. package/src/client/theme/icons/bun.tsx +62 -62
  45. package/src/client/theme/icons/deno.tsx +20 -20
  46. package/src/client/theme/icons/discord.tsx +12 -12
  47. package/src/client/theme/icons/github.tsx +15 -15
  48. package/src/client/theme/icons/npm.tsx +13 -13
  49. package/src/client/theme/icons/pnpm.tsx +72 -72
  50. package/src/client/theme/icons/twitter.tsx +12 -12
  51. package/src/client/theme/styles/markdown.css +343 -343
  52. package/src/client/theme/styles/variables.css +162 -162
  53. package/src/client/theme/styles.css +37 -38
  54. package/src/client/theme/ui/BackgroundGradient/BackgroundGradient.tsx +10 -10
  55. package/src/client/theme/ui/BackgroundGradient/index.ts +1 -1
  56. package/src/client/theme/ui/Breadcrumbs/Breadcrumbs.tsx +68 -68
  57. package/src/client/theme/ui/Breadcrumbs/index.ts +1 -1
  58. package/src/client/theme/ui/Footer/footer.css +32 -32
  59. package/src/client/theme/ui/Head/Head.tsx +69 -69
  60. package/src/client/theme/ui/Head/index.ts +1 -1
  61. package/src/client/theme/ui/LanguageSwitcher/LanguageSwitcher.tsx +125 -125
  62. package/src/client/theme/ui/LanguageSwitcher/index.ts +1 -1
  63. package/src/client/theme/ui/LanguageSwitcher/language-switcher.css +98 -98
  64. package/src/client/theme/ui/Layout/Layout.tsx +202 -213
  65. package/src/client/theme/ui/Layout/base.css +76 -76
  66. package/src/client/theme/ui/Layout/index.ts +2 -2
  67. package/src/client/theme/ui/Layout/pagination.css +72 -72
  68. package/src/client/theme/ui/Layout/responsive.css +36 -40
  69. package/src/client/theme/ui/Link/Link.tsx +254 -202
  70. package/src/client/theme/ui/Link/index.ts +2 -2
  71. package/src/client/theme/ui/Loading/Loading.tsx +10 -10
  72. package/src/client/theme/ui/Loading/index.ts +1 -1
  73. package/src/client/theme/ui/Loading/loading.css +30 -30
  74. package/src/client/theme/ui/Navbar/GithubStars.tsx +27 -27
  75. package/src/client/theme/ui/Navbar/Navbar.tsx +145 -145
  76. package/src/client/theme/ui/Navbar/index.ts +2 -2
  77. package/src/client/theme/ui/Navbar/navbar.css +233 -233
  78. package/src/client/theme/ui/NotFound/NotFound.tsx +19 -20
  79. package/src/client/theme/ui/NotFound/index.ts +1 -1
  80. package/src/client/theme/ui/NotFound/not-found.css +64 -64
  81. package/src/client/theme/ui/OnThisPage/OnThisPage.tsx +235 -192
  82. package/src/client/theme/ui/OnThisPage/index.ts +1 -1
  83. package/src/client/theme/ui/OnThisPage/toc.css +132 -132
  84. package/src/client/theme/ui/PoweredBy/PoweredBy.tsx +18 -18
  85. package/src/client/theme/ui/PoweredBy/index.ts +1 -1
  86. package/src/client/theme/ui/PoweredBy/powered-by.css +76 -76
  87. package/src/client/theme/ui/SearchDialog/SearchDialog.tsx +199 -199
  88. package/src/client/theme/ui/SearchDialog/index.ts +1 -1
  89. package/src/client/theme/ui/SearchDialog/search.css +152 -152
  90. package/src/client/theme/ui/Sidebar/Sidebar.tsx +204 -200
  91. package/src/client/theme/ui/Sidebar/index.ts +1 -1
  92. package/src/client/theme/ui/Sidebar/sidebar.css +236 -269
  93. package/src/client/theme/ui/ThemeToggle/ThemeToggle.tsx +69 -69
  94. package/src/client/theme/ui/ThemeToggle/index.ts +1 -1
  95. package/src/client/theme/ui/VersionSwitcher/VersionSwitcher.tsx +136 -136
  96. package/src/client/theme/ui/VersionSwitcher/index.ts +1 -1
  97. package/src/client/types.ts +50 -50
  98. package/src/client/utils.ts +26 -26
  99. package/src/node/cache.ts +408 -94
  100. package/src/node/config.ts +192 -185
  101. package/src/node/index.ts +21 -21
  102. package/src/node/mdx.ts +120 -41
  103. package/src/node/plugin/entry.ts +58 -58
  104. package/src/node/plugin/html.ts +55 -55
  105. package/src/node/plugin/index.ts +193 -190
  106. package/src/node/plugin/types.ts +11 -11
  107. package/src/node/routes/cache.ts +28 -24
  108. package/src/node/routes/index.ts +167 -152
  109. package/src/node/routes/parser.ts +153 -127
  110. package/src/node/routes/sorter.ts +42 -42
  111. package/src/node/routes/types.ts +49 -49
  112. package/src/node/ssg/index.ts +114 -110
  113. package/src/node/ssg/meta.ts +34 -34
  114. package/src/node/ssg/options.ts +13 -13
  115. package/src/node/ssg/sitemap.ts +54 -54
  116. package/src/node/utils.ts +134 -134
  117. package/tsconfig.json +20 -20
  118. package/tsup.config.ts +22 -22
  119. package/dist/Playground-B2FA34BC.mjs +0 -6
  120. package/dist/chunk-WPT4MWTQ.mjs +0 -89
  121. package/src/client/theme/styles/home.css +0 -60
@@ -1,200 +1,204 @@
1
- import React, { useState } from "react";
2
- import { useLocation } from "react-router-dom";
3
- import { Link } from "../Link";
4
- import { BoltdocsConfig } from "../../../../node/config";
5
- import { PoweredBy } from "../PoweredBy";
6
- import { ChevronRight, ChevronLeft } from "lucide-react";
7
-
8
- interface RouteItem {
9
- path: string;
10
- title: string;
11
- group?: string;
12
- groupTitle?: string;
13
- sidebarPosition?: number;
14
- badge?: string | { text: string; expires?: string };
15
- }
16
-
17
- interface SidebarGroup {
18
- slug: string;
19
- title: string;
20
- routes: RouteItem[];
21
- }
22
-
23
- /**
24
- * Renders a small badge next to sidebar items if one exists and hasn't expired.
25
- */
26
- function renderBadge(badgeRaw: RouteItem["badge"]) {
27
- if (!badgeRaw) return null;
28
-
29
- let text = "";
30
- let expires = "";
31
-
32
- if (typeof badgeRaw === "string") {
33
- text = badgeRaw;
34
- } else {
35
- text = badgeRaw.text;
36
- expires = badgeRaw.expires || "";
37
- }
38
-
39
- // Check expiration
40
- if (expires) {
41
- const expireDate = new Date(expires);
42
- const now = new Date();
43
- // Reset time components for accurate day comparison
44
- expireDate.setHours(0, 0, 0, 0);
45
- now.setHours(0, 0, 0, 0);
46
- if (now > expireDate) {
47
- return null;
48
- }
49
- }
50
-
51
- if (!text) return null;
52
-
53
- if (!text) return null;
54
-
55
- let typeClass = "badge-default";
56
- const lowerText = text.toLowerCase();
57
- if (lowerText === "new") {
58
- typeClass = "badge-new";
59
- } else if (lowerText === "experimental") {
60
- typeClass = "badge-experimental";
61
- } else if (lowerText === "updated") {
62
- typeClass = "badge-updated";
63
- }
64
-
65
- return <span className={`sidebar-badge ${typeClass}`}>{text}</span>;
66
- }
67
-
68
- /**
69
- * The sidebar navigation component.
70
- * Groups documentation routes logically based on the `group` property.
71
- * Highlights the active link based on the current URL path.
72
- *
73
- * @param routes - Array of all generated routes to be displayed
74
- * @param config - Global configuration (which can contain sidebar overrides)
75
- */
76
- export function Sidebar({
77
- routes,
78
- config,
79
- onCollapse,
80
- }: {
81
- routes: RouteItem[];
82
- config: BoltdocsConfig;
83
- onCollapse?: () => void;
84
- }) {
85
- const location = useLocation();
86
-
87
- const ungrouped: RouteItem[] = [];
88
- const groupMap = new Map<string, SidebarGroup>();
89
-
90
- for (const route of routes) {
91
- if (!route.group) {
92
- ungrouped.push(route);
93
- } else {
94
- if (!groupMap.has(route.group)) {
95
- groupMap.set(route.group, {
96
- slug: route.group,
97
- title: route.groupTitle || route.group,
98
- routes: [],
99
- });
100
- }
101
- groupMap.get(route.group)!.routes.push(route);
102
- }
103
- }
104
-
105
- const groups = Array.from(groupMap.values());
106
-
107
- return (
108
- <aside className="boltdocs-sidebar">
109
- <nav aria-label="Main Navigation">
110
- <ul className="sidebar-list">
111
- {ungrouped.map((route) => (
112
- <li key={route.path}>
113
- <Link
114
- to={route.path === "" ? "/" : route.path}
115
- className={`sidebar-link ${location.pathname === route.path ? "active" : ""}`}
116
- aria-current={
117
- location.pathname === route.path ? "page" : undefined
118
- }
119
- >
120
- <div className="sidebar-link-content">
121
- <span>{route.title}</span>
122
- {renderBadge(route.badge)}
123
- </div>
124
- </Link>
125
- </li>
126
- ))}
127
- </ul>
128
-
129
- {groups.map((group) => (
130
- <SidebarGroupSection
131
- key={group.slug}
132
- group={group}
133
- currentPath={location.pathname}
134
- />
135
- ))}
136
- </nav>
137
-
138
- {onCollapse && (
139
- <div className="sidebar-footer">
140
- <button
141
- className="sidebar-collapse-btn"
142
- onClick={onCollapse}
143
- aria-label="Collapse Sidebar"
144
- title="Collapse Sidebar"
145
- >
146
- <ChevronLeft size={16} />
147
- <span>Collapse Sidebar</span>
148
- </button>
149
- </div>
150
- )}
151
-
152
- {config.themeConfig?.poweredBy !== false && <PoweredBy />}
153
- </aside>
154
- );
155
- }
156
-
157
- function SidebarGroupSection({
158
- group,
159
- currentPath,
160
- }: {
161
- group: SidebarGroup;
162
- currentPath: string;
163
- }) {
164
- const isActive = group.routes.some((r) => currentPath === r.path);
165
- const [open, setOpen] = useState(true);
166
-
167
- return (
168
- <div className="sidebar-group">
169
- <button
170
- className={`sidebar-group-header ${isActive ? "active" : ""}`}
171
- onClick={() => setOpen(!open)}
172
- aria-expanded={open}
173
- aria-controls={`sidebar-group-${group.slug}`}
174
- >
175
- <span className="sidebar-group-title">{group.title}</span>
176
- <span className={`sidebar-group-chevron ${open ? "open" : ""}`}>
177
- <ChevronRight size={16} />
178
- </span>
179
- </button>
180
- {open && (
181
- <ul className="sidebar-group-list" id={`sidebar-group-${group.slug}`}>
182
- {group.routes.map((route) => (
183
- <li key={route.path}>
184
- <Link
185
- to={route.path === "" ? "/" : route.path}
186
- className={`sidebar-link sidebar-link-nested ${currentPath === route.path ? "active" : ""}`}
187
- aria-current={currentPath === route.path ? "page" : undefined}
188
- >
189
- <div className="sidebar-link-content">
190
- <span>{route.title}</span>
191
- {renderBadge(route.badge)}
192
- </div>
193
- </Link>
194
- </li>
195
- ))}
196
- </ul>
197
- )}
198
- </div>
199
- );
200
- }
1
+ import React, { useState } from "react";
2
+ import { useLocation } from "react-router-dom";
3
+ import { Link } from "../Link";
4
+ import { BoltdocsConfig } from "../../../../node/config";
5
+ import { PoweredBy } from "../PoweredBy";
6
+ import { ChevronRight, ChevronLeft, PanelLeft } from "lucide-react";
7
+
8
+ interface RouteItem {
9
+ path: string;
10
+ title: string;
11
+ group?: string;
12
+ groupTitle?: string;
13
+ sidebarPosition?: number;
14
+ badge?: string | { text: string; expires?: string };
15
+ }
16
+
17
+ interface SidebarGroup {
18
+ slug: string;
19
+ title: string;
20
+ routes: RouteItem[];
21
+ }
22
+
23
+ /**
24
+ * Renders a small badge next to sidebar items if one exists and hasn't expired.
25
+ */
26
+ function renderBadge(badgeRaw: RouteItem["badge"]) {
27
+ if (!badgeRaw) return null;
28
+
29
+ let text = "";
30
+ let expires = "";
31
+
32
+ if (typeof badgeRaw === "string") {
33
+ text = badgeRaw;
34
+ } else {
35
+ text = badgeRaw.text;
36
+ expires = badgeRaw.expires || "";
37
+ }
38
+
39
+ // Check expiration
40
+ if (expires) {
41
+ const expireDate = new Date(expires);
42
+ const now = new Date();
43
+ // Reset time components for accurate day comparison
44
+ expireDate.setHours(0, 0, 0, 0);
45
+ now.setHours(0, 0, 0, 0);
46
+ if (now > expireDate) {
47
+ return null;
48
+ }
49
+ }
50
+
51
+ if (!text) return null;
52
+
53
+ if (!text) return null;
54
+
55
+ let typeClass = "badge-default";
56
+ const lowerText = text.toLowerCase();
57
+ if (lowerText === "new") {
58
+ typeClass = "badge-new";
59
+ } else if (lowerText === "experimental") {
60
+ typeClass = "badge-experimental";
61
+ } else if (lowerText === "updated") {
62
+ typeClass = "badge-updated";
63
+ }
64
+
65
+ return <span className={`sidebar-badge ${typeClass}`}>{text}</span>;
66
+ }
67
+
68
+ /**
69
+ * The sidebar navigation component.
70
+ * Groups documentation routes logically based on the `group` property.
71
+ * Highlights the active link based on the current URL path.
72
+ *
73
+ * @param routes - Array of all generated routes to be displayed
74
+ * @param config - Global configuration (which can contain sidebar overrides)
75
+ */
76
+ export function Sidebar({
77
+ routes,
78
+ config,
79
+ isCollapsed,
80
+ onToggle,
81
+ }: {
82
+ routes: RouteItem[];
83
+ config: BoltdocsConfig;
84
+ isCollapsed?: boolean;
85
+ onToggle?: () => void;
86
+ }) {
87
+ const location = useLocation();
88
+
89
+ const ungrouped: RouteItem[] = [];
90
+ const groupMap = new Map<string, SidebarGroup>();
91
+
92
+ for (const route of routes) {
93
+ if (!route.group) {
94
+ ungrouped.push(route);
95
+ } else {
96
+ if (!groupMap.has(route.group)) {
97
+ groupMap.set(route.group, {
98
+ slug: route.group,
99
+ title: route.groupTitle || route.group,
100
+ routes: [],
101
+ });
102
+ }
103
+ groupMap.get(route.group)!.routes.push(route);
104
+ }
105
+ }
106
+
107
+ const groups = Array.from(groupMap.values());
108
+
109
+ return (
110
+ <aside className="boltdocs-sidebar">
111
+ {onToggle && (
112
+ <div className="sidebar-collapse">
113
+ <button
114
+ className="sidebar-collapse-btn"
115
+ onClick={onToggle}
116
+ aria-label={isCollapsed ? "Expand Sidebar" : "Collapse Sidebar"}
117
+ title={isCollapsed ? "Expand Sidebar" : "Collapse Sidebar"}
118
+ >
119
+ <PanelLeft size={18} />
120
+ </button>
121
+ </div>
122
+ )}
123
+
124
+ {!isCollapsed && (
125
+ <>
126
+ <nav aria-label="Main Navigation">
127
+ <ul className="sidebar-list">
128
+ {ungrouped.map((route) => (
129
+ <li key={route.path}>
130
+ <Link
131
+ to={route.path === "" ? "/" : route.path}
132
+ className={`sidebar-link ${location.pathname === route.path ? "active" : ""}`}
133
+ aria-current={
134
+ location.pathname === route.path ? "page" : undefined
135
+ }
136
+ >
137
+ <div className="sidebar-link-content">
138
+ <span>{route.title}</span>
139
+ {renderBadge(route.badge)}
140
+ </div>
141
+ </Link>
142
+ </li>
143
+ ))}
144
+ </ul>
145
+
146
+ {groups.map((group) => (
147
+ <SidebarGroupSection
148
+ key={group.slug}
149
+ group={group}
150
+ currentPath={location.pathname}
151
+ />
152
+ ))}
153
+ </nav>
154
+ {config.themeConfig?.poweredBy !== false && <PoweredBy />}
155
+ </>
156
+ )}
157
+ </aside>
158
+ );
159
+ }
160
+
161
+ function SidebarGroupSection({
162
+ group,
163
+ currentPath,
164
+ }: {
165
+ group: SidebarGroup;
166
+ currentPath: string;
167
+ }) {
168
+ const isActive = group.routes.some((r) => currentPath === r.path);
169
+ const [open, setOpen] = useState(true);
170
+
171
+ return (
172
+ <div className="sidebar-group">
173
+ <button
174
+ className={`sidebar-group-header ${isActive ? "active" : ""}`}
175
+ onClick={() => setOpen(!open)}
176
+ aria-expanded={open}
177
+ aria-controls={`sidebar-group-${group.slug}`}
178
+ >
179
+ <span className="sidebar-group-title">{group.title}</span>
180
+ <span className={`sidebar-group-chevron ${open ? "open" : ""}`}>
181
+ <ChevronRight size={16} />
182
+ </span>
183
+ </button>
184
+ {open && (
185
+ <ul className="sidebar-group-list" id={`sidebar-group-${group.slug}`}>
186
+ {group.routes.map((route) => (
187
+ <li key={route.path}>
188
+ <Link
189
+ to={route.path === "" ? "/" : route.path}
190
+ className={`sidebar-link sidebar-link-nested ${currentPath === route.path ? "active" : ""}`}
191
+ aria-current={currentPath === route.path ? "page" : undefined}
192
+ >
193
+ <div className="sidebar-link-content">
194
+ <span>{route.title}</span>
195
+ {renderBadge(route.badge)}
196
+ </div>
197
+ </Link>
198
+ </li>
199
+ ))}
200
+ </ul>
201
+ )}
202
+ </div>
203
+ );
204
+ }
@@ -1 +1 @@
1
- export { Sidebar } from "./Sidebar";
1
+ export { Sidebar } from "./Sidebar";