boltdocs 1.3.0 → 1.3.2
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/dist/{cache-EHR7SXRU.mjs → cache-GQHF6BXI.mjs} +1 -1
- package/dist/{chunk-GSYECEZY.mjs → chunk-CYBWLFOG.mjs} +5 -1
- package/dist/node/index.js +36 -20
- package/dist/node/index.mjs +34 -22
- package/package.json +1 -1
- package/src/client/app/index.tsx +344 -344
- package/src/client/app/preload.tsx +56 -56
- package/src/client/index.ts +40 -40
- package/src/client/ssr.tsx +51 -51
- package/src/client/theme/components/CodeBlock/CodeBlock.tsx +76 -76
- package/src/client/theme/components/CodeBlock/index.ts +1 -1
- package/src/client/theme/components/PackageManagerTabs/PackageManagerTabs.tsx +154 -154
- package/src/client/theme/components/PackageManagerTabs/index.ts +1 -1
- package/src/client/theme/components/PackageManagerTabs/pkg-tabs.css +64 -64
- package/src/client/theme/components/Playground/Playground.tsx +124 -124
- package/src/client/theme/components/Playground/index.ts +1 -1
- package/src/client/theme/components/Playground/playground.css +168 -168
- package/src/client/theme/components/Video/Video.tsx +84 -84
- package/src/client/theme/components/Video/index.ts +1 -1
- package/src/client/theme/components/Video/video.css +41 -41
- package/src/client/theme/components/mdx/Admonition.tsx +80 -80
- package/src/client/theme/components/mdx/Badge.tsx +31 -31
- package/src/client/theme/components/mdx/Button.tsx +50 -50
- package/src/client/theme/components/mdx/Card.tsx +80 -80
- package/src/client/theme/components/mdx/List.tsx +57 -57
- package/src/client/theme/components/mdx/Tabs.tsx +94 -94
- package/src/client/theme/components/mdx/index.ts +18 -18
- package/src/client/theme/components/mdx/mdx-components.css +424 -424
- package/src/client/theme/icons/bun.tsx +62 -62
- package/src/client/theme/icons/deno.tsx +20 -20
- package/src/client/theme/icons/discord.tsx +12 -12
- package/src/client/theme/icons/github.tsx +15 -15
- package/src/client/theme/icons/npm.tsx +13 -13
- package/src/client/theme/icons/pnpm.tsx +72 -72
- package/src/client/theme/icons/twitter.tsx +12 -12
- package/src/client/theme/styles/markdown.css +343 -343
- package/src/client/theme/styles/variables.css +162 -162
- package/src/client/theme/styles.css +37 -37
- package/src/client/theme/ui/BackgroundGradient/BackgroundGradient.tsx +10 -10
- package/src/client/theme/ui/BackgroundGradient/index.ts +1 -1
- package/src/client/theme/ui/Breadcrumbs/Breadcrumbs.tsx +68 -68
- package/src/client/theme/ui/Breadcrumbs/index.ts +1 -1
- package/src/client/theme/ui/Footer/footer.css +32 -32
- package/src/client/theme/ui/Head/Head.tsx +69 -69
- package/src/client/theme/ui/Head/index.ts +1 -1
- package/src/client/theme/ui/LanguageSwitcher/LanguageSwitcher.tsx +125 -125
- package/src/client/theme/ui/LanguageSwitcher/index.ts +1 -1
- package/src/client/theme/ui/LanguageSwitcher/language-switcher.css +98 -98
- package/src/client/theme/ui/Layout/Layout.tsx +202 -202
- package/src/client/theme/ui/Layout/base.css +76 -76
- package/src/client/theme/ui/Layout/index.ts +2 -2
- package/src/client/theme/ui/Layout/pagination.css +72 -72
- package/src/client/theme/ui/Layout/responsive.css +36 -36
- package/src/client/theme/ui/Link/Link.tsx +254 -254
- package/src/client/theme/ui/Link/index.ts +2 -2
- package/src/client/theme/ui/Loading/Loading.tsx +10 -10
- package/src/client/theme/ui/Loading/index.ts +1 -1
- package/src/client/theme/ui/Loading/loading.css +30 -30
- package/src/client/theme/ui/Navbar/GithubStars.tsx +27 -27
- package/src/client/theme/ui/Navbar/Navbar.tsx +145 -145
- package/src/client/theme/ui/Navbar/index.ts +2 -2
- package/src/client/theme/ui/Navbar/navbar.css +233 -233
- package/src/client/theme/ui/NotFound/NotFound.tsx +19 -19
- package/src/client/theme/ui/NotFound/index.ts +1 -1
- package/src/client/theme/ui/NotFound/not-found.css +64 -64
- package/src/client/theme/ui/OnThisPage/OnThisPage.tsx +235 -235
- package/src/client/theme/ui/OnThisPage/index.ts +1 -1
- package/src/client/theme/ui/OnThisPage/toc.css +132 -132
- package/src/client/theme/ui/PoweredBy/PoweredBy.tsx +18 -18
- package/src/client/theme/ui/PoweredBy/index.ts +1 -1
- package/src/client/theme/ui/PoweredBy/powered-by.css +76 -76
- package/src/client/theme/ui/SearchDialog/SearchDialog.tsx +199 -199
- package/src/client/theme/ui/SearchDialog/index.ts +1 -1
- package/src/client/theme/ui/SearchDialog/search.css +152 -152
- package/src/client/theme/ui/Sidebar/Sidebar.tsx +204 -204
- package/src/client/theme/ui/Sidebar/index.ts +1 -1
- package/src/client/theme/ui/Sidebar/sidebar.css +236 -236
- package/src/client/theme/ui/ThemeToggle/ThemeToggle.tsx +69 -69
- package/src/client/theme/ui/ThemeToggle/index.ts +1 -1
- package/src/client/theme/ui/VersionSwitcher/VersionSwitcher.tsx +136 -136
- package/src/client/theme/ui/VersionSwitcher/index.ts +1 -1
- package/src/client/types.ts +50 -50
- package/src/client/utils.ts +26 -26
- package/src/node/cache.ts +408 -408
- package/src/node/config.ts +192 -192
- package/src/node/index.ts +21 -21
- package/src/node/mdx.ts +120 -120
- package/src/node/plugin/entry.ts +58 -58
- package/src/node/plugin/html.ts +55 -55
- package/src/node/plugin/index.ts +193 -193
- package/src/node/plugin/types.ts +11 -11
- package/src/node/routes/cache.ts +28 -28
- package/src/node/routes/index.ts +167 -167
- package/src/node/routes/parser.ts +153 -127
- package/src/node/routes/sorter.ts +42 -42
- package/src/node/routes/types.ts +49 -49
- package/src/node/ssg/index.ts +114 -114
- package/src/node/ssg/meta.ts +33 -34
- package/src/node/ssg/options.ts +13 -13
- package/src/node/ssg/sitemap.ts +55 -54
- package/src/node/utils.ts +145 -134
- package/tsconfig.json +20 -20
- package/tsup.config.ts +22 -22
|
@@ -1,254 +1,254 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
Link as RouterLink,
|
|
4
|
-
NavLink as RouterNavLink,
|
|
5
|
-
LinkProps as RouterLinkProps,
|
|
6
|
-
NavLinkProps as RouterNavLinkProps,
|
|
7
|
-
useLocation,
|
|
8
|
-
useNavigate,
|
|
9
|
-
} from "react-router-dom";
|
|
10
|
-
import { usePreload } from "../../../app/preload";
|
|
11
|
-
import { useConfig } from "../../../app";
|
|
12
|
-
|
|
13
|
-
function useLocalizedTo(to: RouterLinkProps["to"]) {
|
|
14
|
-
const location = useLocation();
|
|
15
|
-
const config = useConfig();
|
|
16
|
-
if (!config || typeof to !== "string") return to;
|
|
17
|
-
if (!config.i18n && !config.versions) return to;
|
|
18
|
-
|
|
19
|
-
const basePath = "/docs";
|
|
20
|
-
if (!to.startsWith(basePath)) return to;
|
|
21
|
-
|
|
22
|
-
// 1. Detect current context from location
|
|
23
|
-
const curSub = location.pathname.substring(basePath.length);
|
|
24
|
-
const curParts = curSub.split("/").filter(Boolean);
|
|
25
|
-
|
|
26
|
-
let currentVersion = config.versions?.defaultVersion;
|
|
27
|
-
let currentLocale = config.i18n?.defaultLocale;
|
|
28
|
-
|
|
29
|
-
let cIdx = 0;
|
|
30
|
-
if (
|
|
31
|
-
config.versions &&
|
|
32
|
-
curParts.length > cIdx &&
|
|
33
|
-
config.versions.versions[curParts[cIdx]]
|
|
34
|
-
) {
|
|
35
|
-
currentVersion = curParts[cIdx];
|
|
36
|
-
cIdx++;
|
|
37
|
-
}
|
|
38
|
-
if (
|
|
39
|
-
config.i18n &&
|
|
40
|
-
curParts.length > cIdx &&
|
|
41
|
-
config.i18n.locales[curParts[cIdx]]
|
|
42
|
-
) {
|
|
43
|
-
currentLocale = curParts[cIdx];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 2. Parse the target `to` path
|
|
47
|
-
const toSub = to.substring(basePath.length);
|
|
48
|
-
const toParts = toSub.split("/").filter(Boolean);
|
|
49
|
-
|
|
50
|
-
let tIdx = 0;
|
|
51
|
-
let hasVersion = false;
|
|
52
|
-
let hasLocale = false;
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
config.versions &&
|
|
56
|
-
toParts.length > tIdx &&
|
|
57
|
-
config.versions.versions[toParts[tIdx]]
|
|
58
|
-
) {
|
|
59
|
-
hasVersion = true;
|
|
60
|
-
tIdx++;
|
|
61
|
-
}
|
|
62
|
-
if (
|
|
63
|
-
config.i18n &&
|
|
64
|
-
toParts.length > tIdx &&
|
|
65
|
-
config.i18n.locales[toParts[tIdx]]
|
|
66
|
-
) {
|
|
67
|
-
hasLocale = true;
|
|
68
|
-
tIdx++;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Extract just the actual route parts
|
|
72
|
-
const routeParts = toParts.slice(tIdx);
|
|
73
|
-
|
|
74
|
-
// Reconstruct path
|
|
75
|
-
const finalParts = [];
|
|
76
|
-
if (config.versions) {
|
|
77
|
-
if (hasVersion) {
|
|
78
|
-
finalParts.push(toParts[0]);
|
|
79
|
-
} else if (currentVersion) {
|
|
80
|
-
finalParts.push(currentVersion);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (config.i18n) {
|
|
84
|
-
if (hasLocale) {
|
|
85
|
-
finalParts.push(toParts[hasVersion ? 1 : 0]);
|
|
86
|
-
} else if (currentLocale) {
|
|
87
|
-
finalParts.push(currentLocale);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
finalParts.push(...routeParts);
|
|
92
|
-
|
|
93
|
-
let finalPath = `${basePath}/${finalParts.join("/")}`;
|
|
94
|
-
if (finalPath.endsWith("/")) {
|
|
95
|
-
finalPath = finalPath.slice(0, -1);
|
|
96
|
-
}
|
|
97
|
-
return finalPath === basePath ? basePath : finalPath;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface LinkProps extends Omit<RouterLinkProps, "prefetch"> {
|
|
101
|
-
/** Should prefetch the page on hover? Options: 'hover' | 'none'. Default 'hover' */
|
|
102
|
-
boltdocsPrefetch?: "hover" | "none";
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
106
|
-
(props, ref) => {
|
|
107
|
-
const {
|
|
108
|
-
boltdocsPrefetch = "hover",
|
|
109
|
-
onMouseEnter,
|
|
110
|
-
onFocus,
|
|
111
|
-
onClick,
|
|
112
|
-
to,
|
|
113
|
-
...rest
|
|
114
|
-
} = props;
|
|
115
|
-
const localizedTo = useLocalizedTo(to);
|
|
116
|
-
const { preload } = usePreload();
|
|
117
|
-
const navigate = useNavigate();
|
|
118
|
-
|
|
119
|
-
const handleMouseEnter = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
120
|
-
onMouseEnter?.(e);
|
|
121
|
-
if (
|
|
122
|
-
boltdocsPrefetch === "hover" &&
|
|
123
|
-
typeof localizedTo === "string" &&
|
|
124
|
-
localizedTo.startsWith("/")
|
|
125
|
-
) {
|
|
126
|
-
preload(localizedTo);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const handleFocus = (e: React.FocusEvent<HTMLAnchorElement>) => {
|
|
131
|
-
onFocus?.(e);
|
|
132
|
-
if (
|
|
133
|
-
boltdocsPrefetch === "hover" &&
|
|
134
|
-
typeof localizedTo === "string" &&
|
|
135
|
-
localizedTo.startsWith("/")
|
|
136
|
-
) {
|
|
137
|
-
preload(localizedTo);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
142
|
-
// Allow user onClick to handle defaults or custom logic
|
|
143
|
-
onClick?.(e);
|
|
144
|
-
|
|
145
|
-
// If default prevented or not a simple left click, don't handle
|
|
146
|
-
if (
|
|
147
|
-
e.defaultPrevented ||
|
|
148
|
-
e.button !== 0 ||
|
|
149
|
-
e.metaKey ||
|
|
150
|
-
e.ctrlKey ||
|
|
151
|
-
e.shiftKey ||
|
|
152
|
-
e.altKey
|
|
153
|
-
) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Intercept navigation to wrap in startTransition
|
|
158
|
-
if (typeof localizedTo === "string" && !localizedTo.startsWith("http")) {
|
|
159
|
-
e.preventDefault();
|
|
160
|
-
React.startTransition(() => {
|
|
161
|
-
navigate(localizedTo);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
<RouterLink
|
|
168
|
-
ref={ref}
|
|
169
|
-
to={localizedTo}
|
|
170
|
-
onMouseEnter={handleMouseEnter}
|
|
171
|
-
onFocus={handleFocus}
|
|
172
|
-
onClick={handleClick}
|
|
173
|
-
{...rest}
|
|
174
|
-
/>
|
|
175
|
-
);
|
|
176
|
-
},
|
|
177
|
-
);
|
|
178
|
-
Link.displayName = "Link";
|
|
179
|
-
|
|
180
|
-
export interface NavLinkProps extends Omit<RouterNavLinkProps, "prefetch"> {
|
|
181
|
-
/** Should prefetch the page on hover? Options: 'hover' | 'none'. Default 'hover' */
|
|
182
|
-
boltdocsPrefetch?: "hover" | "none";
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export const NavLink = React.forwardRef<HTMLAnchorElement, NavLinkProps>(
|
|
186
|
-
(props, ref) => {
|
|
187
|
-
const {
|
|
188
|
-
boltdocsPrefetch = "hover",
|
|
189
|
-
onMouseEnter,
|
|
190
|
-
onFocus,
|
|
191
|
-
onClick,
|
|
192
|
-
to,
|
|
193
|
-
...rest
|
|
194
|
-
} = props;
|
|
195
|
-
|
|
196
|
-
const localizedTo = useLocalizedTo(to);
|
|
197
|
-
const { preload } = usePreload();
|
|
198
|
-
const navigate = useNavigate();
|
|
199
|
-
|
|
200
|
-
const handleMouseEnter = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
201
|
-
onMouseEnter?.(e);
|
|
202
|
-
if (
|
|
203
|
-
boltdocsPrefetch === "hover" &&
|
|
204
|
-
typeof localizedTo === "string" &&
|
|
205
|
-
localizedTo.startsWith("/")
|
|
206
|
-
) {
|
|
207
|
-
preload(localizedTo);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const handleFocus = (e: React.FocusEvent<HTMLAnchorElement>) => {
|
|
212
|
-
onFocus?.(e);
|
|
213
|
-
if (
|
|
214
|
-
boltdocsPrefetch === "hover" &&
|
|
215
|
-
typeof localizedTo === "string" &&
|
|
216
|
-
localizedTo.startsWith("/")
|
|
217
|
-
) {
|
|
218
|
-
preload(localizedTo);
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
223
|
-
onClick?.(e);
|
|
224
|
-
if (
|
|
225
|
-
e.defaultPrevented ||
|
|
226
|
-
e.button !== 0 ||
|
|
227
|
-
e.metaKey ||
|
|
228
|
-
e.ctrlKey ||
|
|
229
|
-
e.shiftKey ||
|
|
230
|
-
e.altKey
|
|
231
|
-
) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
if (typeof localizedTo === "string" && !localizedTo.startsWith("http")) {
|
|
235
|
-
e.preventDefault();
|
|
236
|
-
React.startTransition(() => {
|
|
237
|
-
navigate(localizedTo);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
return (
|
|
243
|
-
<RouterNavLink
|
|
244
|
-
ref={ref}
|
|
245
|
-
to={localizedTo}
|
|
246
|
-
onMouseEnter={handleMouseEnter}
|
|
247
|
-
onFocus={handleFocus}
|
|
248
|
-
onClick={handleClick}
|
|
249
|
-
{...rest}
|
|
250
|
-
/>
|
|
251
|
-
);
|
|
252
|
-
},
|
|
253
|
-
);
|
|
254
|
-
NavLink.displayName = "NavLink";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Link as RouterLink,
|
|
4
|
+
NavLink as RouterNavLink,
|
|
5
|
+
LinkProps as RouterLinkProps,
|
|
6
|
+
NavLinkProps as RouterNavLinkProps,
|
|
7
|
+
useLocation,
|
|
8
|
+
useNavigate,
|
|
9
|
+
} from "react-router-dom";
|
|
10
|
+
import { usePreload } from "../../../app/preload";
|
|
11
|
+
import { useConfig } from "../../../app";
|
|
12
|
+
|
|
13
|
+
function useLocalizedTo(to: RouterLinkProps["to"]) {
|
|
14
|
+
const location = useLocation();
|
|
15
|
+
const config = useConfig();
|
|
16
|
+
if (!config || typeof to !== "string") return to;
|
|
17
|
+
if (!config.i18n && !config.versions) return to;
|
|
18
|
+
|
|
19
|
+
const basePath = "/docs";
|
|
20
|
+
if (!to.startsWith(basePath)) return to;
|
|
21
|
+
|
|
22
|
+
// 1. Detect current context from location
|
|
23
|
+
const curSub = location.pathname.substring(basePath.length);
|
|
24
|
+
const curParts = curSub.split("/").filter(Boolean);
|
|
25
|
+
|
|
26
|
+
let currentVersion = config.versions?.defaultVersion;
|
|
27
|
+
let currentLocale = config.i18n?.defaultLocale;
|
|
28
|
+
|
|
29
|
+
let cIdx = 0;
|
|
30
|
+
if (
|
|
31
|
+
config.versions &&
|
|
32
|
+
curParts.length > cIdx &&
|
|
33
|
+
config.versions.versions[curParts[cIdx]]
|
|
34
|
+
) {
|
|
35
|
+
currentVersion = curParts[cIdx];
|
|
36
|
+
cIdx++;
|
|
37
|
+
}
|
|
38
|
+
if (
|
|
39
|
+
config.i18n &&
|
|
40
|
+
curParts.length > cIdx &&
|
|
41
|
+
config.i18n.locales[curParts[cIdx]]
|
|
42
|
+
) {
|
|
43
|
+
currentLocale = curParts[cIdx];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 2. Parse the target `to` path
|
|
47
|
+
const toSub = to.substring(basePath.length);
|
|
48
|
+
const toParts = toSub.split("/").filter(Boolean);
|
|
49
|
+
|
|
50
|
+
let tIdx = 0;
|
|
51
|
+
let hasVersion = false;
|
|
52
|
+
let hasLocale = false;
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
config.versions &&
|
|
56
|
+
toParts.length > tIdx &&
|
|
57
|
+
config.versions.versions[toParts[tIdx]]
|
|
58
|
+
) {
|
|
59
|
+
hasVersion = true;
|
|
60
|
+
tIdx++;
|
|
61
|
+
}
|
|
62
|
+
if (
|
|
63
|
+
config.i18n &&
|
|
64
|
+
toParts.length > tIdx &&
|
|
65
|
+
config.i18n.locales[toParts[tIdx]]
|
|
66
|
+
) {
|
|
67
|
+
hasLocale = true;
|
|
68
|
+
tIdx++;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Extract just the actual route parts
|
|
72
|
+
const routeParts = toParts.slice(tIdx);
|
|
73
|
+
|
|
74
|
+
// Reconstruct path
|
|
75
|
+
const finalParts = [];
|
|
76
|
+
if (config.versions) {
|
|
77
|
+
if (hasVersion) {
|
|
78
|
+
finalParts.push(toParts[0]);
|
|
79
|
+
} else if (currentVersion) {
|
|
80
|
+
finalParts.push(currentVersion);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (config.i18n) {
|
|
84
|
+
if (hasLocale) {
|
|
85
|
+
finalParts.push(toParts[hasVersion ? 1 : 0]);
|
|
86
|
+
} else if (currentLocale) {
|
|
87
|
+
finalParts.push(currentLocale);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
finalParts.push(...routeParts);
|
|
92
|
+
|
|
93
|
+
let finalPath = `${basePath}/${finalParts.join("/")}`;
|
|
94
|
+
if (finalPath.endsWith("/")) {
|
|
95
|
+
finalPath = finalPath.slice(0, -1);
|
|
96
|
+
}
|
|
97
|
+
return finalPath === basePath ? basePath : finalPath;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface LinkProps extends Omit<RouterLinkProps, "prefetch"> {
|
|
101
|
+
/** Should prefetch the page on hover? Options: 'hover' | 'none'. Default 'hover' */
|
|
102
|
+
boltdocsPrefetch?: "hover" | "none";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
106
|
+
(props, ref) => {
|
|
107
|
+
const {
|
|
108
|
+
boltdocsPrefetch = "hover",
|
|
109
|
+
onMouseEnter,
|
|
110
|
+
onFocus,
|
|
111
|
+
onClick,
|
|
112
|
+
to,
|
|
113
|
+
...rest
|
|
114
|
+
} = props;
|
|
115
|
+
const localizedTo = useLocalizedTo(to);
|
|
116
|
+
const { preload } = usePreload();
|
|
117
|
+
const navigate = useNavigate();
|
|
118
|
+
|
|
119
|
+
const handleMouseEnter = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
120
|
+
onMouseEnter?.(e);
|
|
121
|
+
if (
|
|
122
|
+
boltdocsPrefetch === "hover" &&
|
|
123
|
+
typeof localizedTo === "string" &&
|
|
124
|
+
localizedTo.startsWith("/")
|
|
125
|
+
) {
|
|
126
|
+
preload(localizedTo);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const handleFocus = (e: React.FocusEvent<HTMLAnchorElement>) => {
|
|
131
|
+
onFocus?.(e);
|
|
132
|
+
if (
|
|
133
|
+
boltdocsPrefetch === "hover" &&
|
|
134
|
+
typeof localizedTo === "string" &&
|
|
135
|
+
localizedTo.startsWith("/")
|
|
136
|
+
) {
|
|
137
|
+
preload(localizedTo);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
142
|
+
// Allow user onClick to handle defaults or custom logic
|
|
143
|
+
onClick?.(e);
|
|
144
|
+
|
|
145
|
+
// If default prevented or not a simple left click, don't handle
|
|
146
|
+
if (
|
|
147
|
+
e.defaultPrevented ||
|
|
148
|
+
e.button !== 0 ||
|
|
149
|
+
e.metaKey ||
|
|
150
|
+
e.ctrlKey ||
|
|
151
|
+
e.shiftKey ||
|
|
152
|
+
e.altKey
|
|
153
|
+
) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Intercept navigation to wrap in startTransition
|
|
158
|
+
if (typeof localizedTo === "string" && !localizedTo.startsWith("http")) {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
React.startTransition(() => {
|
|
161
|
+
navigate(localizedTo);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<RouterLink
|
|
168
|
+
ref={ref}
|
|
169
|
+
to={localizedTo}
|
|
170
|
+
onMouseEnter={handleMouseEnter}
|
|
171
|
+
onFocus={handleFocus}
|
|
172
|
+
onClick={handleClick}
|
|
173
|
+
{...rest}
|
|
174
|
+
/>
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
Link.displayName = "Link";
|
|
179
|
+
|
|
180
|
+
export interface NavLinkProps extends Omit<RouterNavLinkProps, "prefetch"> {
|
|
181
|
+
/** Should prefetch the page on hover? Options: 'hover' | 'none'. Default 'hover' */
|
|
182
|
+
boltdocsPrefetch?: "hover" | "none";
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export const NavLink = React.forwardRef<HTMLAnchorElement, NavLinkProps>(
|
|
186
|
+
(props, ref) => {
|
|
187
|
+
const {
|
|
188
|
+
boltdocsPrefetch = "hover",
|
|
189
|
+
onMouseEnter,
|
|
190
|
+
onFocus,
|
|
191
|
+
onClick,
|
|
192
|
+
to,
|
|
193
|
+
...rest
|
|
194
|
+
} = props;
|
|
195
|
+
|
|
196
|
+
const localizedTo = useLocalizedTo(to);
|
|
197
|
+
const { preload } = usePreload();
|
|
198
|
+
const navigate = useNavigate();
|
|
199
|
+
|
|
200
|
+
const handleMouseEnter = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
201
|
+
onMouseEnter?.(e);
|
|
202
|
+
if (
|
|
203
|
+
boltdocsPrefetch === "hover" &&
|
|
204
|
+
typeof localizedTo === "string" &&
|
|
205
|
+
localizedTo.startsWith("/")
|
|
206
|
+
) {
|
|
207
|
+
preload(localizedTo);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const handleFocus = (e: React.FocusEvent<HTMLAnchorElement>) => {
|
|
212
|
+
onFocus?.(e);
|
|
213
|
+
if (
|
|
214
|
+
boltdocsPrefetch === "hover" &&
|
|
215
|
+
typeof localizedTo === "string" &&
|
|
216
|
+
localizedTo.startsWith("/")
|
|
217
|
+
) {
|
|
218
|
+
preload(localizedTo);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
223
|
+
onClick?.(e);
|
|
224
|
+
if (
|
|
225
|
+
e.defaultPrevented ||
|
|
226
|
+
e.button !== 0 ||
|
|
227
|
+
e.metaKey ||
|
|
228
|
+
e.ctrlKey ||
|
|
229
|
+
e.shiftKey ||
|
|
230
|
+
e.altKey
|
|
231
|
+
) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (typeof localizedTo === "string" && !localizedTo.startsWith("http")) {
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
React.startTransition(() => {
|
|
237
|
+
navigate(localizedTo);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<RouterNavLink
|
|
244
|
+
ref={ref}
|
|
245
|
+
to={localizedTo}
|
|
246
|
+
onMouseEnter={handleMouseEnter}
|
|
247
|
+
onFocus={handleFocus}
|
|
248
|
+
onClick={handleClick}
|
|
249
|
+
{...rest}
|
|
250
|
+
/>
|
|
251
|
+
);
|
|
252
|
+
},
|
|
253
|
+
);
|
|
254
|
+
NavLink.displayName = "NavLink";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Link, NavLink } from "./Link";
|
|
2
|
-
export type { LinkProps, NavLinkProps } from "./Link";
|
|
1
|
+
export { Link, NavLink } from "./Link";
|
|
2
|
+
export type { LinkProps, NavLinkProps } from "./Link";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
export function Loading() {
|
|
4
|
-
return (
|
|
5
|
-
<div className="boltdocs-loading">
|
|
6
|
-
<div className="loading-spinner" />
|
|
7
|
-
<p className="loading-text">Loading...</p>
|
|
8
|
-
</div>
|
|
9
|
-
);
|
|
10
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export function Loading() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="boltdocs-loading">
|
|
6
|
+
<div className="loading-spinner" />
|
|
7
|
+
<p className="loading-text">Loading...</p>
|
|
8
|
+
</div>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Loading } from "./Loading";
|
|
1
|
+
export { Loading } from "./Loading";
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
/* ─── Loading ─────────────────────────────────────────────── */
|
|
2
|
-
.boltdocs-loading {
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
align-items: center;
|
|
6
|
-
justify-content: center;
|
|
7
|
-
min-height: 40vh;
|
|
8
|
-
gap: 1rem;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.loading-spinner {
|
|
12
|
-
width: 2.5rem;
|
|
13
|
-
height: 2.5rem;
|
|
14
|
-
border: 3px solid var(--ld-border-subtle);
|
|
15
|
-
border-top-color: var(--ld-color-primary);
|
|
16
|
-
border-radius: 50%;
|
|
17
|
-
animation: boltdocs-spin 0.7s linear infinite;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@keyframes boltdocs-spin {
|
|
21
|
-
to {
|
|
22
|
-
transform: rotate(360deg);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.loading-text {
|
|
27
|
-
font-size: 0.875rem;
|
|
28
|
-
color: var(--ld-text-dim);
|
|
29
|
-
margin: 0;
|
|
30
|
-
}
|
|
1
|
+
/* ─── Loading ─────────────────────────────────────────────── */
|
|
2
|
+
.boltdocs-loading {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
min-height: 40vh;
|
|
8
|
+
gap: 1rem;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.loading-spinner {
|
|
12
|
+
width: 2.5rem;
|
|
13
|
+
height: 2.5rem;
|
|
14
|
+
border: 3px solid var(--ld-border-subtle);
|
|
15
|
+
border-top-color: var(--ld-color-primary);
|
|
16
|
+
border-radius: 50%;
|
|
17
|
+
animation: boltdocs-spin 0.7s linear infinite;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@keyframes boltdocs-spin {
|
|
21
|
+
to {
|
|
22
|
+
transform: rotate(360deg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.loading-text {
|
|
27
|
+
font-size: 0.875rem;
|
|
28
|
+
color: var(--ld-text-dim);
|
|
29
|
+
margin: 0;
|
|
30
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { GitHub } from "../../icons/github";
|
|
3
|
-
import { getStarsRepo } from "../../../utils";
|
|
4
|
-
|
|
5
|
-
export function GithubStars({ repo }: { repo: string }) {
|
|
6
|
-
const [stars, setStars] = useState<string | null>(null);
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (repo) {
|
|
10
|
-
getStarsRepo(repo)
|
|
11
|
-
.then((stars) => setStars(stars))
|
|
12
|
-
.catch(() => setStars("0"));
|
|
13
|
-
}
|
|
14
|
-
}, [repo]);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<a
|
|
18
|
-
href={`https://github.com/${repo}`}
|
|
19
|
-
target="_blank"
|
|
20
|
-
rel="noopener noreferrer"
|
|
21
|
-
className="navbar-github-stars"
|
|
22
|
-
>
|
|
23
|
-
<GitHub />
|
|
24
|
-
{stars && <span>{stars}</span>}
|
|
25
|
-
</a>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { GitHub } from "../../icons/github";
|
|
3
|
+
import { getStarsRepo } from "../../../utils";
|
|
4
|
+
|
|
5
|
+
export function GithubStars({ repo }: { repo: string }) {
|
|
6
|
+
const [stars, setStars] = useState<string | null>(null);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (repo) {
|
|
10
|
+
getStarsRepo(repo)
|
|
11
|
+
.then((stars) => setStars(stars))
|
|
12
|
+
.catch(() => setStars("0"));
|
|
13
|
+
}
|
|
14
|
+
}, [repo]);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<a
|
|
18
|
+
href={`https://github.com/${repo}`}
|
|
19
|
+
target="_blank"
|
|
20
|
+
rel="noopener noreferrer"
|
|
21
|
+
className="navbar-github-stars"
|
|
22
|
+
>
|
|
23
|
+
<GitHub />
|
|
24
|
+
{stars && <span>{stars}</span>}
|
|
25
|
+
</a>
|
|
26
|
+
);
|
|
27
|
+
}
|