boltdocs 3.1.0 → 3.2.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/{adapters-DEXNIv3x.mjs → adapters-ByYY44Zy.mjs} +1 -1
- package/dist/{adapters-uGz-UKQa.cjs → adapters-DvmtpdSF.cjs} +1 -1
- package/dist/{banner-DjujkctF.d.ts → banner-BMop1KLF.d.ts} +2 -2
- package/dist/{banner-DdSgCs4G.d.cts → banner-CVD0GugR.d.cts} +2 -2
- package/dist/{cache-CfRTUzWC.cjs → cache-CO4Dy2uQ.cjs} +1 -1
- package/dist/{cache-B0C2i0yP.mjs → cache-Dk53iOo6.mjs} +1 -1
- package/dist/chunk-BFSpntXv.mjs +6 -0
- package/dist/{chunk-Ds5LZdWN.cjs → chunk-D1Md3oWO.cjs} +1 -1
- package/dist/client/index.cjs +219 -172
- package/dist/client/index.d.cts +75 -9
- package/dist/client/index.d.ts +75 -9
- package/dist/client/index.js +119 -73
- package/dist/client/mdx.cjs +1 -1
- package/dist/client/mdx.d.cts +1 -1
- package/dist/client/mdx.d.ts +1 -1
- package/dist/client/mdx.js +1 -1
- package/dist/client/primitives.cjs +7 -7
- package/dist/client/primitives.d.cts +5 -22
- package/dist/client/primitives.d.ts +5 -22
- package/dist/client/primitives.js +4 -4
- package/dist/client/theme/reset.css +31 -4
- package/dist/{shiki-adapter-fS94vy-z.d.mts → config-BpzaPsJj.d.cts} +325 -78
- package/dist/config-CCXp3aXO.mjs +7 -0
- package/dist/{config-BxsogK5A.cjs → config-CMd4XoFq.cjs} +1 -1
- package/dist/config-DlGoEM9D.cjs +7 -0
- package/dist/{shiki-adapter-l2kEP5rn.d.cts → config-xtS0ZkMm.d.mts} +325 -78
- package/dist/{csp-BX06rvdg.cjs → csp-CRp_3U7a.cjs} +1 -1
- package/dist/csp-oTC2ygvF.mjs +6 -0
- package/dist/{docs-layout-DyLDBwS6.js → docs-layout-BdtZ9z6s.js} +9 -28
- package/dist/{docs-layout-D1buSdua.cjs → docs-layout-CFWI15Id.cjs} +69 -88
- package/dist/{doctor-DPDcRKM1.cjs → doctor-BBtmNJE0.cjs} +1 -1
- package/dist/doctor-Bv16QSrI.cjs +7 -0
- package/dist/doctor-DOAbSaiL.mjs +7 -0
- package/dist/{generator-BN75lJOv.cjs → generator-COepVWGi.cjs} +1 -1
- package/dist/{handler-Btd4t_67.mjs → handler-DzQae4eA.mjs} +1 -1
- package/dist/{handler-1LRMYeI4.cjs → handler-XX7cLTqe.cjs} +1 -1
- package/dist/headers-Ddwek8K7.mjs +6 -0
- package/dist/{headers-YpD10rDb.cjs → headers-dg4SDrjY.cjs} +1 -1
- package/dist/{image-5WsgWYTh.js → image-Bz87fCla.js} +1 -1
- package/dist/{image-Hb105Gu6.cjs → image-C4TlpMHn.cjs} +18 -18
- package/dist/link-2PzgTnaP.js +673 -0
- package/dist/{icons-dev-YtDoLUsb.cjs → link-D1Gjkb-2.cjs} +0 -350
- package/dist/{mdx-Bv-pS6-O.js → mdx-BuO6a1f7.js} +195 -40
- package/dist/{mdx-CDUcJmye.cjs → mdx-CD-tSjRG.cjs} +234 -73
- package/dist/{meta-loader-CTB62-Mo.cjs → meta-loader-Dq1zcFnh.cjs} +1 -1
- package/dist/node/cache.cjs +1 -1
- package/dist/node/cache.d.cts +2 -1
- package/dist/node/cache.d.mts +2 -1
- package/dist/node/cache.mjs +1 -1
- package/dist/node/cli-entry.cjs +6 -6
- package/dist/node/cli-entry.mjs +9 -9
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +20 -174
- package/dist/node/index.d.mts +18 -175
- package/dist/node/index.mjs +1 -1
- package/dist/node/mdx/shiki-adapter.cjs +1 -1
- package/dist/node/mdx/shiki-adapter.d.cts +49 -1
- package/dist/node/mdx/shiki-adapter.d.mts +49 -1
- package/dist/node/mdx/shiki-adapter.mjs +1 -1
- package/dist/node-B5hu_6qj.cjs +104 -0
- package/dist/node-BXtqM1uH.mjs +6 -0
- package/dist/node-C8725aw7.mjs +104 -0
- package/dist/node-aD1eisrR.cjs +6 -0
- package/dist/{package-_-Oa8-qN.cjs → package-CH2ChQqw.cjs} +1 -1
- package/dist/{package-CoHWTf0N.mjs → package-DSSB8B5L.mjs} +1 -1
- package/dist/{pages-external-CX2uyW95.cjs → pages-external-XkYIs-d5.cjs} +1 -1
- package/dist/parser-DCiEWkSk.cjs +8 -0
- package/dist/parser-qk9FIHJ7.mjs +8 -0
- package/dist/plugin-CX1OZ6jB.cjs +73 -0
- package/dist/plugin-CgfiWaFZ.mjs +73 -0
- package/dist/routes-BW6zsk7Z.mjs +6 -0
- package/dist/routes-BgoIB5wb.cjs +6 -0
- package/dist/{routes-D_S9kjkS.cjs → routes-CORVxc02.cjs} +1 -1
- package/dist/{search-dialog-BpNULmrl.cjs → search-dialog-B1NERUNx.cjs} +101 -55
- package/dist/{search-dialog-BbtxA1uT.cjs → search-dialog-BRFno7HD.cjs} +8 -8
- package/dist/{search-dialog-DC7oXU-5.js → search-dialog-BmxHiKwt.js} +2 -2
- package/dist/{search-dialog-gp9lrJXm.js → search-dialog-D6TvjcuV.js} +1 -1
- package/dist/{search-dialog-PJrFRU5G.js → search-dialog-DFnlx8LO.js} +44 -4
- package/dist/{search-dialog-BIuxGQsg.cjs → search-dialog-DHqwjJuG.cjs} +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/shiki-adapter-CoQ6jyJ4.cjs +6 -0
- package/dist/shiki-adapter-D-aKw7PP.mjs +6 -0
- package/dist/{sidebar-DknLUI1R.d.ts → sidebar-COTaMHR-.d.ts} +349 -41
- package/dist/{sidebar-DH2iPKXM.d.cts → sidebar-CrEdJuHX.d.cts} +349 -41
- package/dist/{types-generator-CYcHkDzZ.cjs → types-generator-BXhv7Ill.cjs} +1 -1
- package/dist/types-generator-bDPvUztF.mjs +26 -0
- package/dist/utils-Crm9oPcV.mjs +7 -0
- package/dist/utils-D6Xtj0FZ.cjs +7 -0
- package/package.json +13 -10
- package/src/shared/types.ts +361 -19
- package/dist/chunk-hT5z_Zn9-DsJawvsz.mjs +0 -6
- package/dist/chunk-hT5z_Zn9-SKz6VFXu.cjs +0 -6
- package/dist/config-DAgpZyh6.mjs +0 -7
- package/dist/config-DrRQYDCI.cjs +0 -7
- package/dist/csp-z2D0FuRW.mjs +0 -6
- package/dist/doctor-BadGEhXv.cjs +0 -7
- package/dist/doctor-vDsUDgqp.mjs +0 -7
- package/dist/escape-string-regexp-AG8q1e25-9Un9V90q.mjs +0 -6
- package/dist/escape-string-regexp-AG8q1e25-bJ9Ixe7c.cjs +0 -6
- package/dist/esm-shims-DSep1HcR.mjs +0 -6
- package/dist/headers-CL0pMcwm.mjs +0 -6
- package/dist/icons-dev-CHZOwhQA.js +0 -921
- package/dist/lib-BR0SoanK-CLswltLI.cjs +0 -6
- package/dist/lib-BR0SoanK-DcYeDrE6.mjs +0 -6
- package/dist/lib-DPoCz1YB-CLYXwKST.cjs +0 -6
- package/dist/lib-DPoCz1YB-CyGOqgSO.mjs +0 -6
- package/dist/micromark-util-character-5KqJafVT-C6gnc770.cjs +0 -6
- package/dist/micromark-util-character-5KqJafVT-DkPKsbgn.mjs +0 -6
- package/dist/node-BDBv8CT6.mjs +0 -104
- package/dist/node-DFV_FV0y.mjs +0 -6
- package/dist/node-DqsP7kXz.cjs +0 -6
- package/dist/node-yFmAavND.cjs +0 -104
- package/dist/parser-BZJgAa9E.mjs +0 -8
- package/dist/parser-DlanzESE.cjs +0 -8
- package/dist/plugin-BVuwx5D9.cjs +0 -73
- package/dist/plugin-BoxD91Yh.mjs +0 -73
- package/dist/rehype-slug--ZOxZ-_K-BNeYC4aT.cjs +0 -6
- package/dist/rehype-slug--ZOxZ-_K-CjIQEJCs.mjs +0 -6
- package/dist/remark-frontmatter-wFYRLcCt-CutW0gA3.mjs +0 -8
- package/dist/remark-frontmatter-wFYRLcCt-ENB5qG3y.cjs +0 -8
- package/dist/remark-gfm-B8TMkQbX-CjUJo8Rd.cjs +0 -21
- package/dist/remark-gfm-B8TMkQbX-Ctu0VV1_.mjs +0 -21
- package/dist/rolldown-runtime-fkIsjY3S.mjs +0 -6
- package/dist/rollup-DMqoG11U-CKcJ37u_.mjs +0 -59
- package/dist/rollup-DMqoG11U-DKdxvZIj.cjs +0 -59
- package/dist/routes-BN2XbGcT.mjs +0 -6
- package/dist/routes-Cnq8xTCv.cjs +0 -6
- package/dist/shiki-adapter-CGTmrR6S.cjs +0 -6
- package/dist/shiki-adapter-CK3llqw2.mjs +0 -6
- package/dist/types-generator-DVOnRVKU.mjs +0 -26
- package/dist/utils-B3xYMrpK.mjs +0 -7
- package/dist/utils-Bz1tG9Dg.cjs +0 -7
- /package/dist/{errors-C0Hx15Ag.mjs → errors-0zGHRLue.mjs} +0 -0
- /package/dist/{errors-Dx6JHoKE.cjs → errors-vKw8CkiX.cjs} +0 -0
- /package/dist/{index-DJYJzs-Z.d.mts → index-1KsTDq4o.d.mts} +0 -0
- /package/dist/{meta-loader-Bq-MjTXB.mjs → meta-loader-C4Hu9RN9.mjs} +0 -0
|
@@ -0,0 +1,673 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { clsx } from "clsx";
|
|
10
|
+
import { twMerge } from "tailwind-merge";
|
|
11
|
+
|
|
12
|
+
//#region \0rolldown/runtime.js
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __exportAll = (all, no_symbols) => {
|
|
15
|
+
let target = {};
|
|
16
|
+
for (var name in all) {
|
|
17
|
+
__defProp(target, name, {
|
|
18
|
+
get: all[name],
|
|
19
|
+
enumerable: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (!no_symbols) {
|
|
23
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
24
|
+
}
|
|
25
|
+
return target;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/client/store/boltdocs-context.tsx
|
|
30
|
+
const PREFERENCES_KEY = "boltdocs-user-preferences";
|
|
31
|
+
const BOLTDOCS_CONTEXT_SYMBOL = Symbol.for("__BDOCS_BOLTDOCS_CONTEXT__");
|
|
32
|
+
const BOLTDOCS_INSTANCE_SYMBOL = Symbol.for("__BDOCS_BOLTDOCS_INSTANCE__");
|
|
33
|
+
const BoltdocsContext = globalThis[BOLTDOCS_CONTEXT_SYMBOL] || (globalThis[BOLTDOCS_CONTEXT_SYMBOL] = createContext(void 0));
|
|
34
|
+
function BoltdocsProvider({ children, initialLocale = "", initialVersion = "" }) {
|
|
35
|
+
const getSavedPrefs = () => {
|
|
36
|
+
if (typeof window === "undefined") return {};
|
|
37
|
+
try {
|
|
38
|
+
const raw = window.localStorage.getItem(PREFERENCES_KEY);
|
|
39
|
+
return raw ? JSON.parse(raw) : {};
|
|
40
|
+
} catch {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const [locale, setLocaleState] = useState(() => {
|
|
45
|
+
if (initialLocale) return initialLocale;
|
|
46
|
+
return getSavedPrefs().locale || "";
|
|
47
|
+
});
|
|
48
|
+
const [version, setVersionState] = useState(() => {
|
|
49
|
+
if (initialVersion) return initialVersion;
|
|
50
|
+
return getSavedPrefs().version || "";
|
|
51
|
+
});
|
|
52
|
+
const [hasHydrated, setHasHydrated] = useState(() => {
|
|
53
|
+
return typeof window !== "undefined";
|
|
54
|
+
});
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
setHasHydrated(true);
|
|
57
|
+
}, []);
|
|
58
|
+
const value = useMemo(() => {
|
|
59
|
+
const updateLocale = (l) => {
|
|
60
|
+
const newL = l || "";
|
|
61
|
+
setLocaleState(newL);
|
|
62
|
+
if (typeof window !== "undefined") try {
|
|
63
|
+
const prefs = getSavedPrefs();
|
|
64
|
+
window.localStorage.setItem(PREFERENCES_KEY, JSON.stringify({
|
|
65
|
+
...prefs,
|
|
66
|
+
locale: newL
|
|
67
|
+
}));
|
|
68
|
+
} catch (e) {}
|
|
69
|
+
};
|
|
70
|
+
const updateVersion = (v) => {
|
|
71
|
+
const newV = v || "";
|
|
72
|
+
setVersionState(newV);
|
|
73
|
+
if (typeof window !== "undefined") try {
|
|
74
|
+
const prefs = getSavedPrefs();
|
|
75
|
+
window.localStorage.setItem(PREFERENCES_KEY, JSON.stringify({
|
|
76
|
+
...prefs,
|
|
77
|
+
version: newV
|
|
78
|
+
}));
|
|
79
|
+
} catch (e) {}
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
currentLocale: locale,
|
|
83
|
+
currentVersion: version,
|
|
84
|
+
setLocale: updateLocale,
|
|
85
|
+
setVersion: updateVersion,
|
|
86
|
+
hasHydrated,
|
|
87
|
+
setHasHydrated
|
|
88
|
+
};
|
|
89
|
+
}, [
|
|
90
|
+
locale,
|
|
91
|
+
version,
|
|
92
|
+
hasHydrated
|
|
93
|
+
]);
|
|
94
|
+
if (typeof globalThis !== "undefined") globalThis[BOLTDOCS_INSTANCE_SYMBOL] = value;
|
|
95
|
+
return /* @__PURE__ */ jsx(BoltdocsContext.Provider, {
|
|
96
|
+
value,
|
|
97
|
+
children
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function useBoltdocsContext() {
|
|
101
|
+
const context = use(BoltdocsContext);
|
|
102
|
+
if (!context && typeof globalThis !== "undefined" && globalThis[BOLTDOCS_INSTANCE_SYMBOL]) return globalThis[BOLTDOCS_INSTANCE_SYMBOL];
|
|
103
|
+
if (!context) throw new Error("useBoltdocsContext must be used within a BoltdocsProvider");
|
|
104
|
+
return context;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/client/app/config-context.tsx
|
|
109
|
+
/**
|
|
110
|
+
* Context for the global documentation configuration.
|
|
111
|
+
* Using a global singleton pattern to survive dual-package or duplicated-code hazards.
|
|
112
|
+
*/
|
|
113
|
+
const CONFIG_CONTEXT_SYMBOL = Symbol.for("__BDOCS_CONFIG_CONTEXT__");
|
|
114
|
+
const CONFIG_INSTANCE_SYMBOL = Symbol.for("__BDOCS_CONFIG_INSTANCE__");
|
|
115
|
+
const ConfigContext = globalThis[CONFIG_CONTEXT_SYMBOL] || (globalThis[CONFIG_CONTEXT_SYMBOL] = createContext(null));
|
|
116
|
+
/**
|
|
117
|
+
* Hook to access the Boltdocs configuration.
|
|
118
|
+
*/
|
|
119
|
+
function useConfig() {
|
|
120
|
+
const context = use(ConfigContext);
|
|
121
|
+
if (!context && typeof globalThis !== "undefined" && globalThis[CONFIG_INSTANCE_SYMBOL]) return globalThis[CONFIG_INSTANCE_SYMBOL];
|
|
122
|
+
if (!context) throw new Error("useConfig must be used within a ConfigProvider");
|
|
123
|
+
return context;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/client/components/ui-base/icons.tsx
|
|
128
|
+
var icons_exports = /* @__PURE__ */ __exportAll({
|
|
129
|
+
AlertCircle: () => AlertCircle,
|
|
130
|
+
AlertTriangle: () => AlertTriangle,
|
|
131
|
+
ArrowLeft: () => ArrowLeft,
|
|
132
|
+
Check: () => Check,
|
|
133
|
+
ChevronDown: () => ChevronDown,
|
|
134
|
+
ChevronLeft: () => ChevronLeft,
|
|
135
|
+
ChevronRight: () => ChevronRight,
|
|
136
|
+
CircleHelp: () => CircleHelp,
|
|
137
|
+
Copy: () => Copy,
|
|
138
|
+
CornerDownLeft: () => CornerDownLeft,
|
|
139
|
+
ExternalLink: () => ExternalLink,
|
|
140
|
+
FaceBad: () => FaceBad,
|
|
141
|
+
FaceGood: () => FaceGood,
|
|
142
|
+
FaceRegular: () => FaceRegular,
|
|
143
|
+
File: () => File,
|
|
144
|
+
FileText: () => FileText,
|
|
145
|
+
Hash: () => Hash,
|
|
146
|
+
Home: () => Home,
|
|
147
|
+
Info: () => Info,
|
|
148
|
+
Languages: () => Languages,
|
|
149
|
+
Lightbulb: () => Lightbulb,
|
|
150
|
+
Link: () => Link$2,
|
|
151
|
+
Menu: () => Menu,
|
|
152
|
+
Monitor: () => Monitor,
|
|
153
|
+
Moon: () => Moon,
|
|
154
|
+
MoreVertical: () => MoreVertical,
|
|
155
|
+
Pencil: () => Pencil,
|
|
156
|
+
Search: () => Search,
|
|
157
|
+
Sun: () => Sun,
|
|
158
|
+
TextAlignStart: () => TextAlignStart,
|
|
159
|
+
X: () => X
|
|
160
|
+
});
|
|
161
|
+
function createIcon(displayName, paths, viewBox = "0 0 24 24") {
|
|
162
|
+
const Component = ({ size = 24, className, ...props }) => {
|
|
163
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
164
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
165
|
+
width: size,
|
|
166
|
+
height: size,
|
|
167
|
+
viewBox,
|
|
168
|
+
fill: "none",
|
|
169
|
+
stroke: "currentColor",
|
|
170
|
+
strokeWidth: "2",
|
|
171
|
+
strokeLinecap: "round",
|
|
172
|
+
strokeLinejoin: "round",
|
|
173
|
+
className,
|
|
174
|
+
...props,
|
|
175
|
+
children: [/* @__PURE__ */ jsx("title", { children: displayName }), paths]
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
Component.displayName = displayName;
|
|
179
|
+
return Component;
|
|
180
|
+
}
|
|
181
|
+
const Info = createIcon("Info", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
182
|
+
/* @__PURE__ */ jsx("circle", {
|
|
183
|
+
cx: "12",
|
|
184
|
+
cy: "12",
|
|
185
|
+
r: "10"
|
|
186
|
+
}),
|
|
187
|
+
/* @__PURE__ */ jsx("path", { d: "M12 16v-4" }),
|
|
188
|
+
/* @__PURE__ */ jsx("path", { d: "M12 8h.01" })
|
|
189
|
+
] }));
|
|
190
|
+
const Lightbulb = createIcon("Lightbulb", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
191
|
+
/* @__PURE__ */ jsx("path", { d: "M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A5 5 0 0 0 8 8c0 1 .3 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" }),
|
|
192
|
+
/* @__PURE__ */ jsx("path", { d: "M9 18h6" }),
|
|
193
|
+
/* @__PURE__ */ jsx("path", { d: "M10 22h4" })
|
|
194
|
+
] }));
|
|
195
|
+
const AlertTriangle = createIcon("AlertTriangle", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
196
|
+
/* @__PURE__ */ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
|
|
197
|
+
/* @__PURE__ */ jsx("line", {
|
|
198
|
+
x1: "12",
|
|
199
|
+
y1: "9",
|
|
200
|
+
x2: "12",
|
|
201
|
+
y2: "13"
|
|
202
|
+
}),
|
|
203
|
+
/* @__PURE__ */ jsx("line", {
|
|
204
|
+
x1: "12",
|
|
205
|
+
y1: "17",
|
|
206
|
+
x2: "12.01",
|
|
207
|
+
y2: "17"
|
|
208
|
+
})
|
|
209
|
+
] }));
|
|
210
|
+
const AlertCircle = createIcon("AlertCircle", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
211
|
+
/* @__PURE__ */ jsx("circle", {
|
|
212
|
+
cx: "12",
|
|
213
|
+
cy: "12",
|
|
214
|
+
r: "10"
|
|
215
|
+
}),
|
|
216
|
+
/* @__PURE__ */ jsx("line", {
|
|
217
|
+
x1: "12",
|
|
218
|
+
y1: "8",
|
|
219
|
+
x2: "12",
|
|
220
|
+
y2: "12"
|
|
221
|
+
}),
|
|
222
|
+
/* @__PURE__ */ jsx("line", {
|
|
223
|
+
x1: "12",
|
|
224
|
+
y1: "16",
|
|
225
|
+
x2: "12.01",
|
|
226
|
+
y2: "16"
|
|
227
|
+
})
|
|
228
|
+
] }));
|
|
229
|
+
const Copy = createIcon("Copy", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("rect", {
|
|
230
|
+
width: "14",
|
|
231
|
+
height: "14",
|
|
232
|
+
x: "8",
|
|
233
|
+
y: "8",
|
|
234
|
+
rx: "2",
|
|
235
|
+
ry: "2"
|
|
236
|
+
}), /* @__PURE__ */ jsx("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })] }));
|
|
237
|
+
const Check = createIcon("Check", /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }));
|
|
238
|
+
const File = createIcon("File", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }), /* @__PURE__ */ jsx("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" })] }));
|
|
239
|
+
const ArrowLeft = createIcon("ArrowLeft", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "m12 19-7-7 7-7" }), /* @__PURE__ */ jsx("path", { d: "M19 12H5" })] }));
|
|
240
|
+
const Pencil = createIcon("Pencil", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "M12 20h9" }), /* @__PURE__ */ jsx("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })] }));
|
|
241
|
+
const CircleHelp = createIcon("CircleHelp", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
242
|
+
/* @__PURE__ */ jsx("circle", {
|
|
243
|
+
cx: "12",
|
|
244
|
+
cy: "12",
|
|
245
|
+
r: "10"
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ jsx("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }),
|
|
248
|
+
/* @__PURE__ */ jsx("path", { d: "M12 17h.01" })
|
|
249
|
+
] }));
|
|
250
|
+
const TextAlignStart = createIcon("TextAlignStart", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
251
|
+
/* @__PURE__ */ jsx("line", {
|
|
252
|
+
x1: "21",
|
|
253
|
+
x2: "3",
|
|
254
|
+
y1: "6",
|
|
255
|
+
y2: "6"
|
|
256
|
+
}),
|
|
257
|
+
/* @__PURE__ */ jsx("line", {
|
|
258
|
+
x1: "15",
|
|
259
|
+
x2: "3",
|
|
260
|
+
y1: "12",
|
|
261
|
+
y2: "12"
|
|
262
|
+
}),
|
|
263
|
+
/* @__PURE__ */ jsx("line", {
|
|
264
|
+
x1: "17",
|
|
265
|
+
x2: "3",
|
|
266
|
+
y1: "18",
|
|
267
|
+
y2: "18"
|
|
268
|
+
})
|
|
269
|
+
] }));
|
|
270
|
+
const ExternalLink = createIcon("ExternalLink", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
271
|
+
/* @__PURE__ */ jsx("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
272
|
+
/* @__PURE__ */ jsx("polyline", { points: "15 3 21 3 21 9" }),
|
|
273
|
+
/* @__PURE__ */ jsx("line", {
|
|
274
|
+
x1: "10",
|
|
275
|
+
y1: "14",
|
|
276
|
+
x2: "21",
|
|
277
|
+
y2: "3"
|
|
278
|
+
})
|
|
279
|
+
] }));
|
|
280
|
+
const ChevronDown = createIcon("ChevronDown", /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }));
|
|
281
|
+
const Home = createIcon("Home", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" }), /* @__PURE__ */ jsx("polyline", { points: "9 22 9 12 15 12 15 22" })] }));
|
|
282
|
+
const Search = createIcon("Search", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
|
|
283
|
+
cx: "11",
|
|
284
|
+
cy: "11",
|
|
285
|
+
r: "8"
|
|
286
|
+
}), /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })] }));
|
|
287
|
+
const Sun = createIcon("Sun", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
288
|
+
/* @__PURE__ */ jsx("circle", {
|
|
289
|
+
cx: "12",
|
|
290
|
+
cy: "12",
|
|
291
|
+
r: "4"
|
|
292
|
+
}),
|
|
293
|
+
/* @__PURE__ */ jsx("path", { d: "M12 2v2" }),
|
|
294
|
+
/* @__PURE__ */ jsx("path", { d: "M12 20v2" }),
|
|
295
|
+
/* @__PURE__ */ jsx("path", { d: "m4.93 4.93 1.41 1.41" }),
|
|
296
|
+
/* @__PURE__ */ jsx("path", { d: "m17.66 17.66 1.41 1.41" }),
|
|
297
|
+
/* @__PURE__ */ jsx("path", { d: "M2 12h2" }),
|
|
298
|
+
/* @__PURE__ */ jsx("path", { d: "M20 12h2" }),
|
|
299
|
+
/* @__PURE__ */ jsx("path", { d: "m6.34 17.66-1.41 1.41" }),
|
|
300
|
+
/* @__PURE__ */ jsx("path", { d: "m19.07 4.93-1.41 1.41" })
|
|
301
|
+
] }));
|
|
302
|
+
const Moon = createIcon("Moon", /* @__PURE__ */ jsx("path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }));
|
|
303
|
+
const Monitor = createIcon("Monitor", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
304
|
+
/* @__PURE__ */ jsx("rect", {
|
|
305
|
+
width: "20",
|
|
306
|
+
height: "14",
|
|
307
|
+
x: "2",
|
|
308
|
+
y: "3",
|
|
309
|
+
rx: "2"
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ jsx("line", {
|
|
312
|
+
x1: "8",
|
|
313
|
+
x2: "16",
|
|
314
|
+
y1: "21",
|
|
315
|
+
y2: "21"
|
|
316
|
+
}),
|
|
317
|
+
/* @__PURE__ */ jsx("line", {
|
|
318
|
+
x1: "12",
|
|
319
|
+
x2: "12",
|
|
320
|
+
y1: "17",
|
|
321
|
+
y2: "21"
|
|
322
|
+
})
|
|
323
|
+
] }));
|
|
324
|
+
const Languages = createIcon("Languages", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
325
|
+
/* @__PURE__ */ jsx("path", { d: "m5 8 6 6" }),
|
|
326
|
+
/* @__PURE__ */ jsx("path", { d: "m4 14 6-6 2-3" }),
|
|
327
|
+
/* @__PURE__ */ jsx("path", { d: "M2 5h12" }),
|
|
328
|
+
/* @__PURE__ */ jsx("path", { d: "M7 2h1" }),
|
|
329
|
+
/* @__PURE__ */ jsx("path", { d: "m22 22-5-10-5 10" }),
|
|
330
|
+
/* @__PURE__ */ jsx("path", { d: "M14 18h6" })
|
|
331
|
+
] }));
|
|
332
|
+
const Menu = createIcon("Menu", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
333
|
+
/* @__PURE__ */ jsx("line", {
|
|
334
|
+
x1: "4",
|
|
335
|
+
x2: "20",
|
|
336
|
+
y1: "12",
|
|
337
|
+
y2: "12"
|
|
338
|
+
}),
|
|
339
|
+
/* @__PURE__ */ jsx("line", {
|
|
340
|
+
x1: "4",
|
|
341
|
+
x2: "20",
|
|
342
|
+
y1: "6",
|
|
343
|
+
y2: "6"
|
|
344
|
+
}),
|
|
345
|
+
/* @__PURE__ */ jsx("line", {
|
|
346
|
+
x1: "4",
|
|
347
|
+
x2: "20",
|
|
348
|
+
y1: "18",
|
|
349
|
+
y2: "18"
|
|
350
|
+
})
|
|
351
|
+
] }));
|
|
352
|
+
const X = createIcon("X", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })] }));
|
|
353
|
+
const Link$2 = createIcon("Link", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), /* @__PURE__ */ jsx("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })] }));
|
|
354
|
+
const ChevronRight = createIcon("ChevronRight", /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }));
|
|
355
|
+
const MoreVertical = createIcon("MoreVertical", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
356
|
+
/* @__PURE__ */ jsx("circle", {
|
|
357
|
+
cx: "12",
|
|
358
|
+
cy: "12",
|
|
359
|
+
r: "1"
|
|
360
|
+
}),
|
|
361
|
+
/* @__PURE__ */ jsx("circle", {
|
|
362
|
+
cx: "12",
|
|
363
|
+
cy: "5",
|
|
364
|
+
r: "1"
|
|
365
|
+
}),
|
|
366
|
+
/* @__PURE__ */ jsx("circle", {
|
|
367
|
+
cx: "12",
|
|
368
|
+
cy: "19",
|
|
369
|
+
r: "1"
|
|
370
|
+
})
|
|
371
|
+
] }));
|
|
372
|
+
const ChevronLeft = createIcon("ChevronLeft", /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }));
|
|
373
|
+
const Hash = createIcon("Hash", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
374
|
+
/* @__PURE__ */ jsx("line", {
|
|
375
|
+
x1: "4",
|
|
376
|
+
x2: "20",
|
|
377
|
+
y1: "9",
|
|
378
|
+
y2: "9"
|
|
379
|
+
}),
|
|
380
|
+
/* @__PURE__ */ jsx("line", {
|
|
381
|
+
x1: "4",
|
|
382
|
+
x2: "20",
|
|
383
|
+
y1: "15",
|
|
384
|
+
y2: "15"
|
|
385
|
+
}),
|
|
386
|
+
/* @__PURE__ */ jsx("line", {
|
|
387
|
+
x1: "10",
|
|
388
|
+
x2: "8",
|
|
389
|
+
y1: "3",
|
|
390
|
+
y2: "21"
|
|
391
|
+
}),
|
|
392
|
+
/* @__PURE__ */ jsx("line", {
|
|
393
|
+
x1: "16",
|
|
394
|
+
x2: "14",
|
|
395
|
+
y1: "3",
|
|
396
|
+
y2: "21"
|
|
397
|
+
})
|
|
398
|
+
] }));
|
|
399
|
+
const FileText = createIcon("FileText", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
400
|
+
/* @__PURE__ */ jsx("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }),
|
|
401
|
+
/* @__PURE__ */ jsx("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }),
|
|
402
|
+
/* @__PURE__ */ jsx("path", { d: "M10 9H8" }),
|
|
403
|
+
/* @__PURE__ */ jsx("path", { d: "M16 13H8" }),
|
|
404
|
+
/* @__PURE__ */ jsx("path", { d: "M16 17H8" })
|
|
405
|
+
] }));
|
|
406
|
+
const CornerDownLeft = createIcon("CornerDownLeft", /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("polyline", { points: "9 10 4 15 9 20" }), /* @__PURE__ */ jsx("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" })] }));
|
|
407
|
+
const FaceGood = createIcon("FaceGood", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
408
|
+
/* @__PURE__ */ jsx("circle", {
|
|
409
|
+
cx: "12",
|
|
410
|
+
cy: "12",
|
|
411
|
+
r: "10"
|
|
412
|
+
}),
|
|
413
|
+
/* @__PURE__ */ jsx("path", { d: "M8 14s1.5 2 4 2 4-2 4-2" }),
|
|
414
|
+
/* @__PURE__ */ jsx("line", {
|
|
415
|
+
x1: "9",
|
|
416
|
+
y1: "9",
|
|
417
|
+
x2: "9.01",
|
|
418
|
+
y2: "9"
|
|
419
|
+
}),
|
|
420
|
+
/* @__PURE__ */ jsx("line", {
|
|
421
|
+
x1: "15",
|
|
422
|
+
y1: "9",
|
|
423
|
+
x2: "15.01",
|
|
424
|
+
y2: "9"
|
|
425
|
+
})
|
|
426
|
+
] }));
|
|
427
|
+
const FaceRegular = createIcon("FaceRegular", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
428
|
+
/* @__PURE__ */ jsx("circle", {
|
|
429
|
+
cx: "12",
|
|
430
|
+
cy: "12",
|
|
431
|
+
r: "10"
|
|
432
|
+
}),
|
|
433
|
+
/* @__PURE__ */ jsx("line", {
|
|
434
|
+
x1: "8",
|
|
435
|
+
y1: "15",
|
|
436
|
+
x2: "16",
|
|
437
|
+
y2: "15"
|
|
438
|
+
}),
|
|
439
|
+
/* @__PURE__ */ jsx("line", {
|
|
440
|
+
x1: "9",
|
|
441
|
+
y1: "9",
|
|
442
|
+
x2: "9.01",
|
|
443
|
+
y2: "9"
|
|
444
|
+
}),
|
|
445
|
+
/* @__PURE__ */ jsx("line", {
|
|
446
|
+
x1: "15",
|
|
447
|
+
y1: "9",
|
|
448
|
+
x2: "15.01",
|
|
449
|
+
y2: "9"
|
|
450
|
+
})
|
|
451
|
+
] }));
|
|
452
|
+
const FaceBad = createIcon("FaceBad", /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
453
|
+
/* @__PURE__ */ jsx("circle", {
|
|
454
|
+
cx: "12",
|
|
455
|
+
cy: "12",
|
|
456
|
+
r: "10"
|
|
457
|
+
}),
|
|
458
|
+
/* @__PURE__ */ jsx("path", { d: "M16 16s-1.5-2-4-2-4 2-4 2" }),
|
|
459
|
+
/* @__PURE__ */ jsx("line", {
|
|
460
|
+
x1: "9",
|
|
461
|
+
y1: "9",
|
|
462
|
+
x2: "9.01",
|
|
463
|
+
y2: "9"
|
|
464
|
+
}),
|
|
465
|
+
/* @__PURE__ */ jsx("line", {
|
|
466
|
+
x1: "15",
|
|
467
|
+
y1: "9",
|
|
468
|
+
x2: "15.01",
|
|
469
|
+
y2: "9"
|
|
470
|
+
})
|
|
471
|
+
] }));
|
|
472
|
+
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/client/app/routes-context.tsx
|
|
475
|
+
const RoutesContext = createContext({ routes: [] });
|
|
476
|
+
/**
|
|
477
|
+
* Hook to access the processed routes list from the closest provider.
|
|
478
|
+
*/
|
|
479
|
+
function useRoutesContext() {
|
|
480
|
+
return use(RoutesContext);
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Provider component for the documentation routes.
|
|
484
|
+
*/
|
|
485
|
+
function RoutesProvider({ routes, children }) {
|
|
486
|
+
return /* @__PURE__ */ jsx(RoutesContext.Provider, {
|
|
487
|
+
value: { routes },
|
|
488
|
+
children
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/client/utils/path.ts
|
|
494
|
+
/**
|
|
495
|
+
* Normalizes a URL path by stripping any trailing slash unless it's the root path.
|
|
496
|
+
*
|
|
497
|
+
* @param p - The path to normalize.
|
|
498
|
+
* @returns The normalized path.
|
|
499
|
+
*/
|
|
500
|
+
function normalizePath(p) {
|
|
501
|
+
return p.endsWith("/") && p.length > 1 ? p.slice(0, -1) : p;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/client/hooks/use-routes.ts
|
|
506
|
+
/**
|
|
507
|
+
* Hook to access the framework's routing state.
|
|
508
|
+
* Returns both the complete set of routes and a filtered list based on the current
|
|
509
|
+
* version and locale.
|
|
510
|
+
*/
|
|
511
|
+
function useRoutes() {
|
|
512
|
+
const { routes: allRoutes } = useRoutesContext();
|
|
513
|
+
const config = useConfig();
|
|
514
|
+
const location = useLocation();
|
|
515
|
+
const { currentLocale: currentLocaleStore, currentVersion: currentVersionStore } = useBoltdocsContext();
|
|
516
|
+
const currentPath = normalizePath(location.pathname);
|
|
517
|
+
const currentRoute = allRoutes?.find?.((r) => normalizePath(r.path) === currentPath);
|
|
518
|
+
const currentLocale = config.i18n ? currentLocaleStore || config.i18n.defaultLocale : void 0;
|
|
519
|
+
const currentVersion = config.versions ? currentVersionStore || config.versions.defaultVersion : void 0;
|
|
520
|
+
const routes = useMemo(() => {
|
|
521
|
+
if (!allRoutes) return [];
|
|
522
|
+
const alternateCounts = /* @__PURE__ */ new Map();
|
|
523
|
+
const defaultLocale = config.i18n?.defaultLocale || "";
|
|
524
|
+
const defaultVersion = config.versions?.defaultVersion || "";
|
|
525
|
+
for (const r of allRoutes) {
|
|
526
|
+
const locale = r.locale || defaultLocale;
|
|
527
|
+
const version = r.version || defaultVersion;
|
|
528
|
+
const key = `${r.filePath}::${locale}::${version}`;
|
|
529
|
+
alternateCounts.set(key, (alternateCounts.get(key) || 0) + 1);
|
|
530
|
+
}
|
|
531
|
+
return allRoutes.filter((r) => {
|
|
532
|
+
const localeMatch = config.i18n ? (r.locale || config.i18n.defaultLocale) === currentLocale : true;
|
|
533
|
+
const versionMatch = config.versions ? (r.version || config.versions.defaultVersion) === currentVersion : true;
|
|
534
|
+
if (!(localeMatch && versionMatch)) return false;
|
|
535
|
+
const pathParts = location.pathname.split("/").filter(Boolean);
|
|
536
|
+
const isCurrentLocalePrefixed = !!(config.i18n && pathParts.includes(currentLocaleStore || config.i18n.defaultLocale));
|
|
537
|
+
const isCurrentVersionPrefixed = !!(config.versions && pathParts.includes(currentVersionStore || config.versions.defaultVersion));
|
|
538
|
+
const isRouteLocalePrefixed = !!r.locale;
|
|
539
|
+
const isRouteVersionPrefixed = !!r.version;
|
|
540
|
+
const locale = r.locale || defaultLocale;
|
|
541
|
+
const version = r.version || defaultVersion;
|
|
542
|
+
const key = `${r.filePath}::${locale}::${version}`;
|
|
543
|
+
if ((alternateCounts.get(key) || 0) > 1) {
|
|
544
|
+
const localeMismatch = config.i18n && isCurrentLocalePrefixed !== isRouteLocalePrefixed;
|
|
545
|
+
const versionMismatch = config.versions && isCurrentVersionPrefixed !== isRouteVersionPrefixed;
|
|
546
|
+
if (localeMismatch || versionMismatch) return false;
|
|
547
|
+
}
|
|
548
|
+
return true;
|
|
549
|
+
});
|
|
550
|
+
}, [
|
|
551
|
+
allRoutes,
|
|
552
|
+
config,
|
|
553
|
+
currentLocale,
|
|
554
|
+
currentVersion,
|
|
555
|
+
location.pathname,
|
|
556
|
+
currentLocaleStore,
|
|
557
|
+
currentVersionStore
|
|
558
|
+
]);
|
|
559
|
+
const collections = useMemo(() => {
|
|
560
|
+
return new Set((allRoutes || []).map((r) => r.collection).filter(Boolean));
|
|
561
|
+
}, [allRoutes]);
|
|
562
|
+
const currentSegment = location.pathname.split("/").filter(Boolean)[0]?.toLowerCase();
|
|
563
|
+
return {
|
|
564
|
+
routes,
|
|
565
|
+
allRoutes,
|
|
566
|
+
currentRoute,
|
|
567
|
+
isCollectionPage: !!currentRoute?.collection || (currentSegment ? collections.has(currentSegment) : false),
|
|
568
|
+
currentLocale,
|
|
569
|
+
currentVersion
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
//#endregion
|
|
574
|
+
//#region src/client/hooks/use-localized-to.ts
|
|
575
|
+
function useLocalizedTo(to) {
|
|
576
|
+
const config = useConfig();
|
|
577
|
+
const { currentLocale: activeLocale, currentVersion: activeVersion, allRoutes } = useRoutes();
|
|
578
|
+
if (!config || typeof to !== "string") return to;
|
|
579
|
+
if (to.startsWith("http") || to.startsWith("//") || to.startsWith("#")) return to;
|
|
580
|
+
if (to.startsWith("site:")) {
|
|
581
|
+
to = to.replace("site:", "");
|
|
582
|
+
if (to === "" || to === "/") return config.i18n && activeLocale && activeLocale !== config.i18n.defaultLocale ? `/${activeLocale}` : "/";
|
|
583
|
+
return to;
|
|
584
|
+
}
|
|
585
|
+
const [pathOnly, hashAndQuery] = to.split(/([?#].*)/s);
|
|
586
|
+
const normalizedTo = pathOnly.endsWith("/") && pathOnly.length > 1 ? pathOnly.slice(0, -1) : pathOnly;
|
|
587
|
+
const isKnownRoute = allRoutes?.some((r) => {
|
|
588
|
+
return (r.path.endsWith("/") && r.path.length > 1 ? r.path.slice(0, -1) : r.path) === (normalizedTo || "/");
|
|
589
|
+
});
|
|
590
|
+
const i18n = config.i18n;
|
|
591
|
+
const versions = config.versions;
|
|
592
|
+
const base = (config.base || "/docs").replace(/\/$/, "");
|
|
593
|
+
const baseSegment = base.startsWith("/") ? base.substring(1) : base;
|
|
594
|
+
const rawParts = pathOnly.split("/").filter(Boolean);
|
|
595
|
+
const isDocsPath = baseSegment && rawParts.length > 0 && rawParts[0] === baseSegment || !isKnownRoute && rawParts.length > 0;
|
|
596
|
+
const parts = [...rawParts];
|
|
597
|
+
let pIdx = 0;
|
|
598
|
+
if (baseSegment && parts[pIdx] === baseSegment) pIdx++;
|
|
599
|
+
if (versions && parts.length > pIdx) {
|
|
600
|
+
if (versions.versions.find((v) => v.path === parts[pIdx])) pIdx++;
|
|
601
|
+
}
|
|
602
|
+
if (i18n && parts.length > pIdx && (Array.isArray(i18n.locales) ? i18n.locales.includes(parts[pIdx]) : parts[pIdx] in i18n.locales)) pIdx++;
|
|
603
|
+
const routeContent = parts.slice(pIdx);
|
|
604
|
+
const resultParts = [];
|
|
605
|
+
if (isDocsPath) {
|
|
606
|
+
if (baseSegment) resultParts.push(baseSegment);
|
|
607
|
+
if (versions && activeVersion) resultParts.push(activeVersion);
|
|
608
|
+
if (i18n && activeLocale && activeLocale !== i18n.defaultLocale) resultParts.push(activeLocale);
|
|
609
|
+
} else if (i18n && activeLocale && activeLocale !== i18n.defaultLocale) resultParts.push(activeLocale);
|
|
610
|
+
resultParts.push(...routeContent);
|
|
611
|
+
let finalPath = `/${resultParts.join("/")}`;
|
|
612
|
+
if (pathOnly.endsWith("/") && pathOnly.length > 1 && !finalPath.endsWith("/")) finalPath += "/";
|
|
613
|
+
return (finalPath || "/") + (hashAndQuery || "");
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/client/utils/cn.ts
|
|
618
|
+
function cn(...inputs) {
|
|
619
|
+
return twMerge(clsx(inputs));
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
//#endregion
|
|
623
|
+
//#region src/client/components/primitives/link.tsx
|
|
624
|
+
/**
|
|
625
|
+
* A primitive Link component that wraps a standard anchor tag
|
|
626
|
+
* and adds framework-specific logic for path localization and preloading.
|
|
627
|
+
*/
|
|
628
|
+
function Link$1(props) {
|
|
629
|
+
const { href, onMouseEnter, onFocus, onClick, ...rest } = props;
|
|
630
|
+
const navigate = useNavigate();
|
|
631
|
+
const localizedHref = useLocalizedTo(href ?? "");
|
|
632
|
+
const handleClick = (e) => {
|
|
633
|
+
onClick?.(e);
|
|
634
|
+
if (e.defaultPrevented) return;
|
|
635
|
+
if (!(localizedHref && (localizedHref.startsWith("http://") || localizedHref.startsWith("https://") || localizedHref.startsWith("//")))) {
|
|
636
|
+
e.preventDefault();
|
|
637
|
+
navigate(localizedHref);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
const handleMouseEnter = (e) => {
|
|
641
|
+
onMouseEnter?.(e);
|
|
642
|
+
};
|
|
643
|
+
const handleFocus = (e) => {
|
|
644
|
+
onFocus?.(e);
|
|
645
|
+
};
|
|
646
|
+
return /* @__PURE__ */ jsx("a", {
|
|
647
|
+
...rest,
|
|
648
|
+
href: localizedHref,
|
|
649
|
+
onClick: handleClick,
|
|
650
|
+
onMouseEnter: handleMouseEnter,
|
|
651
|
+
onFocus: handleFocus
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* A primitive NavLink component that provides active state detection.
|
|
656
|
+
*/
|
|
657
|
+
function NavLink(props) {
|
|
658
|
+
const { href, end = false, className, children, ...rest } = props;
|
|
659
|
+
const location = useLocation();
|
|
660
|
+
const localizedHref = useLocalizedTo(href ?? "");
|
|
661
|
+
const isActive = end ? location.pathname === localizedHref : location.pathname.startsWith(localizedHref);
|
|
662
|
+
const resolvedClassName = typeof className === "function" ? className({ isActive }) : cn(className, isActive && "active");
|
|
663
|
+
const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
|
|
664
|
+
return /* @__PURE__ */ jsx(Link$1, {
|
|
665
|
+
...rest,
|
|
666
|
+
href,
|
|
667
|
+
className: resolvedClassName,
|
|
668
|
+
children: resolvedChildren
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
//#endregion
|
|
673
|
+
export { Monitor as A, useConfig as B, Hash as C, Lightbulb as D, Languages as E, Sun as F, useBoltdocsContext as H, TextAlignStart as I, X as L, MoreVertical as M, Pencil as N, Link$2 as O, Search as P, icons_exports as R, FileText as S, Info as T, BoltdocsProvider as V, CornerDownLeft as _, useRoutes as a, FaceGood as b, AlertCircle as c, Check as d, ChevronDown as f, Copy as g, CircleHelp as h, useLocalizedTo as i, Moon as j, Menu as k, AlertTriangle as l, ChevronRight as m, NavLink as n, normalizePath as o, ChevronLeft as p, cn as r, RoutesProvider as s, Link$1 as t, ArrowLeft as u, ExternalLink as v, Home as w, FaceRegular as x, FaceBad as y, ConfigContext as z };
|