@next-library/theme 1.0.7 → 1.0.9
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/client.js +180 -91
- package/dist/client.js.map +1 -1
- package/dist/components/markdown/markdown-renderer.d.ts +17 -1
- package/dist/components/markdown/markdown-renderer.d.ts.map +1 -1
- package/dist/components/navigation/navbar/mobile-menu.d.ts.map +1 -1
- package/dist/components/navigation/sidebar-left/sidebar.d.ts +7 -1
- package/dist/components/navigation/sidebar-left/sidebar.d.ts.map +1 -1
- package/dist/index.js +180 -91
- package/dist/index.js.map +1 -1
- package/dist/lib/mobile-menu-store.d.ts +3 -0
- package/dist/lib/mobile-menu-store.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
interface MarkdownRendererProps {
|
|
2
2
|
markdown: string;
|
|
3
3
|
className?: string;
|
|
4
|
+
/**
|
|
5
|
+
* Directory of the current page within the docs tree, locale-agnostic and
|
|
6
|
+
* without a trailing filename (e.g. `offensive/.../api` for an index page, or
|
|
7
|
+
* `offensive/.../api/graphql` for a leaf page). Relative `.md` links in the
|
|
8
|
+
* markdown are resolved against this so they become working site routes.
|
|
9
|
+
*/
|
|
10
|
+
baseDir?: string;
|
|
11
|
+
/** Current locale, used to build the `/<locale>/docs/...` route prefix. */
|
|
12
|
+
locale?: string;
|
|
4
13
|
}
|
|
5
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a relative markdown link (e.g. `../database/index.md`) to a working
|
|
16
|
+
* site route (`/<locale>/docs/offensive/.../database`). Returns null for links
|
|
17
|
+
* that must be left untouched: external, protocol, mailto, anchor-only,
|
|
18
|
+
* already-absolute, or non-`.md` targets.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveInternalDocHref(href: string | undefined, baseDir: string | undefined, locale: string | undefined): string | null;
|
|
21
|
+
export declare function MarkdownRenderer({ markdown, className, baseDir, locale }: MarkdownRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
6
22
|
export {};
|
|
7
23
|
//# sourceMappingURL=markdown-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/markdown/markdown-renderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/markdown/markdown-renderer.tsx"],"names":[],"mappings":"AAiBA,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,GAAG,IAAI,CAqBf;AA4KD,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,SAAc,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,qBAAqB,2CAgBpG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/navbar/mobile-menu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/navbar/mobile-menu.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE;QACb,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;KAChC,CAAC;CACH;AAED,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,YAAiB,EAAE,EAAE,eAAe,kDAuD1E"}
|
|
@@ -4,10 +4,16 @@ interface SidebarNavigationProps {
|
|
|
4
4
|
nodes: SidebarNode[];
|
|
5
5
|
currentPath?: string;
|
|
6
6
|
language?: Locale;
|
|
7
|
+
/**
|
|
8
|
+
* Called when a leaf page (a node with no children) is clicked. The mobile
|
|
9
|
+
* menu uses this to close the drawer once the user reaches an actual page,
|
|
10
|
+
* while folder navigations that only drill down leave the menu open.
|
|
11
|
+
*/
|
|
12
|
+
onNavigateLeaf?: () => void;
|
|
7
13
|
translations?: {
|
|
8
14
|
toggleFolder?: string;
|
|
9
15
|
};
|
|
10
16
|
}
|
|
11
|
-
export declare function SidebarNavigation({ nodes, currentPath, language: _language, translations, }: SidebarNavigationProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function SidebarNavigation({ nodes, currentPath, language: _language, onNavigateLeaf, translations, }: SidebarNavigationProps): import("react/jsx-runtime").JSX.Element;
|
|
12
18
|
export {};
|
|
13
19
|
//# sourceMappingURL=sidebar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/sidebar-left/sidebar.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAUtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,UAAU,sBAAsB;IAC9B,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE;QACb,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAsBD,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,WAAW,EACX,QAAQ,EAAE,SAAgB,EAC1B,YAAiB,GAClB,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/sidebar-left/sidebar.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAUtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,UAAU,sBAAsB;IAC9B,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE;QACb,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAsBD,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,WAAW,EACX,QAAQ,EAAE,SAAgB,EAC1B,cAAc,EACd,YAAiB,GAClB,EAAE,sBAAsB,2CAyGxB"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React8 from 'react';
|
|
2
|
-
import React8__default, { Suspense, useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
+
import React8__default, { Suspense, useState, useRef, useEffect, useCallback, useMemo, useSyncExternalStore } from 'react';
|
|
3
3
|
import { Logo, TopCategories, SearchBar, GithubLink, ThemeSwitcher, LanguageSwitcher, MobileMenu, GithubStar, ReadingProgress, Banner, CookieBanner, SidebarNavigation, GithubContributors, TableOfContents, CopyPageButton } from '@next-library/theme/client';
|
|
4
4
|
import { FALLBACK_LOCALES, getDirection, getTopCategories, getSupportedLocales, getLocaleConfig, LOCALES_CONFIG } from '@next-library/core';
|
|
5
5
|
export { extractLocaleFromPathname, extractPageData, getLocaleFromParams } from '@next-library/core';
|
|
@@ -3351,7 +3351,7 @@ function StickyBanner({
|
|
|
3351
3351
|
locale = "en",
|
|
3352
3352
|
closeLabel
|
|
3353
3353
|
}) {
|
|
3354
|
-
const [
|
|
3354
|
+
const [open2, setOpen] = useState(true);
|
|
3355
3355
|
const { scrollY } = useScroll();
|
|
3356
3356
|
const translations2 = getTranslations(locale);
|
|
3357
3357
|
const ariaLabel = closeLabel || translations2.closeBanner;
|
|
@@ -3374,8 +3374,8 @@ function StickyBanner({
|
|
|
3374
3374
|
opacity: 0
|
|
3375
3375
|
},
|
|
3376
3376
|
animate: {
|
|
3377
|
-
y:
|
|
3378
|
-
opacity:
|
|
3377
|
+
y: open2 ? 0 : -100,
|
|
3378
|
+
opacity: open2 ? 1 : 0
|
|
3379
3379
|
},
|
|
3380
3380
|
transition: {
|
|
3381
3381
|
duration: 0.3,
|
|
@@ -3393,7 +3393,7 @@ function StickyBanner({
|
|
|
3393
3393
|
scale: 1
|
|
3394
3394
|
},
|
|
3395
3395
|
className: "absolute top-1/2 right-2 -translate-y-1/2 cursor-pointer",
|
|
3396
|
-
onClick: () => setOpen(!
|
|
3396
|
+
onClick: () => setOpen(!open2),
|
|
3397
3397
|
"aria-label": ariaLabel,
|
|
3398
3398
|
children: /* @__PURE__ */ jsx(CloseIcon, { className: "h-5 w-5 text-white", "aria-hidden": "true" })
|
|
3399
3399
|
}
|
|
@@ -3545,7 +3545,7 @@ function SearchBar2({ language = "en", className }) {
|
|
|
3545
3545
|
const router = useRouter();
|
|
3546
3546
|
const translations2 = getTranslations(language);
|
|
3547
3547
|
const [mounted, setMounted] = useState(false);
|
|
3548
|
-
const [
|
|
3548
|
+
const [open2, setOpen] = useState(false);
|
|
3549
3549
|
const [query, setQuery] = useState("");
|
|
3550
3550
|
const [results, setResults] = useState([]);
|
|
3551
3551
|
const [recent, setRecent] = useState([]);
|
|
@@ -3592,7 +3592,7 @@ function SearchBar2({ language = "en", className }) {
|
|
|
3592
3592
|
return () => window.removeEventListener("keydown", onKey);
|
|
3593
3593
|
}, [isMac]);
|
|
3594
3594
|
useEffect(() => {
|
|
3595
|
-
if (!
|
|
3595
|
+
if (!open2) return;
|
|
3596
3596
|
setRecent(readRecent());
|
|
3597
3597
|
const t = setTimeout(() => inputRef.current?.focus(), 20);
|
|
3598
3598
|
const prev = document.body.style.overflow;
|
|
@@ -3601,9 +3601,9 @@ function SearchBar2({ language = "en", className }) {
|
|
|
3601
3601
|
clearTimeout(t);
|
|
3602
3602
|
document.body.style.overflow = prev;
|
|
3603
3603
|
};
|
|
3604
|
-
}, [
|
|
3604
|
+
}, [open2]);
|
|
3605
3605
|
useEffect(() => {
|
|
3606
|
-
if (!
|
|
3606
|
+
if (!open2) return;
|
|
3607
3607
|
if (!query.trim()) {
|
|
3608
3608
|
setResults([]);
|
|
3609
3609
|
setIsLoading(false);
|
|
@@ -3624,10 +3624,10 @@ function SearchBar2({ language = "en", className }) {
|
|
|
3624
3624
|
}
|
|
3625
3625
|
}, 180);
|
|
3626
3626
|
return () => clearTimeout(id2);
|
|
3627
|
-
}, [query, language,
|
|
3627
|
+
}, [query, language, open2]);
|
|
3628
3628
|
const flat = useMemo(() => query.trim() ? results : [], [query, results]);
|
|
3629
3629
|
useEffect(() => {
|
|
3630
|
-
if (!
|
|
3630
|
+
if (!open2) return;
|
|
3631
3631
|
const onKey = (e) => {
|
|
3632
3632
|
if (e.key === "Escape") {
|
|
3633
3633
|
e.preventDefault();
|
|
@@ -3646,7 +3646,7 @@ function SearchBar2({ language = "en", className }) {
|
|
|
3646
3646
|
};
|
|
3647
3647
|
window.addEventListener("keydown", onKey);
|
|
3648
3648
|
return () => window.removeEventListener("keydown", onKey);
|
|
3649
|
-
}, [
|
|
3649
|
+
}, [open2, flat, selected, close, go]);
|
|
3650
3650
|
useEffect(() => {
|
|
3651
3651
|
const node = listRef.current?.querySelector('[data-selected="true"]');
|
|
3652
3652
|
node?.scrollIntoView({ block: "nearest" });
|
|
@@ -3673,7 +3673,7 @@ function SearchBar2({ language = "en", className }) {
|
|
|
3673
3673
|
]
|
|
3674
3674
|
}
|
|
3675
3675
|
);
|
|
3676
|
-
const modal =
|
|
3676
|
+
const modal = open2 && mounted ? createPortal(
|
|
3677
3677
|
/* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-[100] flex items-start justify-center p-4 pt-[12vh]", role: "dialog", "aria-modal": "true", children: [
|
|
3678
3678
|
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-background/70 backdrop-blur-sm", onClick: close, "aria-hidden": "true" }),
|
|
3679
3679
|
/* @__PURE__ */ jsx("div", { className: "cl-beam relative w-full max-w-xl shadow-[0_30px_90px_-24px_rgb(0_0_0/0.55)]", children: /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-[calc(var(--radius)+2px)] bg-popover", children: [
|
|
@@ -4383,10 +4383,10 @@ function SidebarProvider({
|
|
|
4383
4383
|
const isMobile = useIsMobile();
|
|
4384
4384
|
const [openMobile, setOpenMobile] = React8.useState(false);
|
|
4385
4385
|
const [_open, _setOpen] = React8.useState(defaultOpen);
|
|
4386
|
-
const
|
|
4386
|
+
const open2 = openProp ?? _open;
|
|
4387
4387
|
const setOpen = React8.useCallback(
|
|
4388
4388
|
(value) => {
|
|
4389
|
-
const openState = typeof value === "function" ? value(
|
|
4389
|
+
const openState = typeof value === "function" ? value(open2) : value;
|
|
4390
4390
|
if (setOpenProp) {
|
|
4391
4391
|
setOpenProp(openState);
|
|
4392
4392
|
} else {
|
|
@@ -4394,10 +4394,10 @@ function SidebarProvider({
|
|
|
4394
4394
|
}
|
|
4395
4395
|
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
4396
4396
|
},
|
|
4397
|
-
[setOpenProp,
|
|
4397
|
+
[setOpenProp, open2]
|
|
4398
4398
|
);
|
|
4399
4399
|
const toggleSidebar = React8.useCallback(() => {
|
|
4400
|
-
return isMobile ? setOpenMobile((
|
|
4400
|
+
return isMobile ? setOpenMobile((open3) => !open3) : setOpen((open3) => !open3);
|
|
4401
4401
|
}, [isMobile, setOpen, setOpenMobile]);
|
|
4402
4402
|
React8.useEffect(() => {
|
|
4403
4403
|
const handleKeyDown = (event) => {
|
|
@@ -4409,18 +4409,18 @@ function SidebarProvider({
|
|
|
4409
4409
|
window.addEventListener("keydown", handleKeyDown);
|
|
4410
4410
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
4411
4411
|
}, [toggleSidebar]);
|
|
4412
|
-
const state =
|
|
4412
|
+
const state = open2 ? "expanded" : "collapsed";
|
|
4413
4413
|
const contextValue = React8.useMemo(
|
|
4414
4414
|
() => ({
|
|
4415
4415
|
state,
|
|
4416
|
-
open,
|
|
4416
|
+
open: open2,
|
|
4417
4417
|
setOpen,
|
|
4418
4418
|
isMobile,
|
|
4419
4419
|
openMobile,
|
|
4420
4420
|
setOpenMobile,
|
|
4421
4421
|
toggleSidebar
|
|
4422
4422
|
}),
|
|
4423
|
-
[state,
|
|
4423
|
+
[state, open2, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
4424
4424
|
);
|
|
4425
4425
|
return /* @__PURE__ */ jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsx(
|
|
4426
4426
|
"div",
|
|
@@ -4960,6 +4960,7 @@ function SidebarNavigation2({
|
|
|
4960
4960
|
nodes,
|
|
4961
4961
|
currentPath,
|
|
4962
4962
|
language: _language = "en",
|
|
4963
|
+
onNavigateLeaf,
|
|
4963
4964
|
translations: translations2 = {}
|
|
4964
4965
|
}) {
|
|
4965
4966
|
const { toggleFolder = "Toggle folder" } = translations2;
|
|
@@ -4967,65 +4968,76 @@ function SidebarNavigation2({
|
|
|
4967
4968
|
if (!node.websitePath) return null;
|
|
4968
4969
|
const isActive = isActiveNode(node, currentPath);
|
|
4969
4970
|
const hasActiveChildNode = hasActiveChild(node, currentPath);
|
|
4970
|
-
return node.children && Object.keys(node.children).length > 0 ? /* @__PURE__ */ jsx(
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
{
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
children
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
4971
|
+
return node.children && Object.keys(node.children).length > 0 ? /* @__PURE__ */ jsx(
|
|
4972
|
+
Collapsible,
|
|
4973
|
+
{
|
|
4974
|
+
defaultOpen: isActive || hasActiveChildNode,
|
|
4975
|
+
className: "group/collapsible",
|
|
4976
|
+
children: /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsxs(SidebarMenuItem, { children: [
|
|
4977
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-nowrap items-center gap-2", children: [
|
|
4978
|
+
/* @__PURE__ */ jsxs(
|
|
4979
|
+
Link2,
|
|
4980
|
+
{
|
|
4981
|
+
href: node.websitePath,
|
|
4982
|
+
className: `group/row relative flex flex-nowrap items-center gap-2 flex-auto py-1.5 pl-3 pr-2 rounded-md text-sm transition-colors hover:bg-accent ${isActive ? "bg-accent font-medium text-foreground before:absolute before:inset-y-1 before:left-0 before:w-0.5 before:rounded-full before:bg-foreground" : hasActiveChildNode ? "text-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
4983
|
+
children: [
|
|
4984
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-none", children: [
|
|
4985
|
+
/* @__PURE__ */ jsx(FolderOpenIcon, { className: "h-4 w-4 group-data-[state=closed]/collapsible:hidden" }),
|
|
4986
|
+
/* @__PURE__ */ jsx(FolderClosedIcon, { className: "h-4 w-4 group-data-[state=open]/collapsible:hidden" })
|
|
4987
|
+
] }),
|
|
4988
|
+
/* @__PURE__ */ jsx("span", { className: `flex-auto ${isActive ? "font-medium" : ""}`, children: node.title })
|
|
4989
|
+
]
|
|
4990
|
+
}
|
|
4991
|
+
),
|
|
4992
|
+
/* @__PURE__ */ jsxs(
|
|
4993
|
+
CollapsibleTrigger2,
|
|
4994
|
+
{
|
|
4995
|
+
className: "p-1.5 rounded-md text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground self-center",
|
|
4996
|
+
"aria-label": `${toggleFolder}: ${node.title}`,
|
|
4997
|
+
children: [
|
|
4998
|
+
/* @__PURE__ */ jsx(
|
|
4999
|
+
ChevronRight,
|
|
5000
|
+
{
|
|
5001
|
+
className: "h-4 w-4 group-data-[state=open]/collapsible:hidden",
|
|
5002
|
+
"aria-hidden": "true"
|
|
5003
|
+
}
|
|
5004
|
+
),
|
|
5005
|
+
/* @__PURE__ */ jsx(
|
|
5006
|
+
ChevronDown,
|
|
5007
|
+
{
|
|
5008
|
+
className: "h-4 w-4 group-data-[state=closed]/collapsible:hidden",
|
|
5009
|
+
"aria-hidden": "true"
|
|
5010
|
+
}
|
|
5011
|
+
)
|
|
5012
|
+
]
|
|
5013
|
+
}
|
|
5014
|
+
)
|
|
5015
|
+
] }),
|
|
5016
|
+
/* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: Object.entries(node.children || {}).map(([, child]) => {
|
|
5017
|
+
if (!child.websitePath) return null;
|
|
5018
|
+
const isChildActive = isActiveNode(child, currentPath);
|
|
5019
|
+
const childIsLeaf = !child.children || Object.keys(child.children).length === 0;
|
|
5020
|
+
return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(
|
|
5021
|
+
Link2,
|
|
5022
|
+
{
|
|
5023
|
+
href: child.websitePath,
|
|
5024
|
+
onClick: childIsLeaf ? onNavigateLeaf : void 0,
|
|
5025
|
+
className: `group/row relative flex items-center gap-2 py-1.5 pl-3 pr-2 rounded-md text-sm transition-colors hover:bg-accent ${isChildActive ? "bg-accent font-medium text-foreground before:absolute before:inset-y-1 before:left-0 before:w-0.5 before:rounded-full before:bg-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
5026
|
+
children: [
|
|
5027
|
+
child.children && Object.keys(child.children).length > 0 ? /* @__PURE__ */ jsx(FolderClosedIcon, { className: "h-4 w-4 flex-none" }) : /* @__PURE__ */ jsx(FileTextIcon, { className: "h-4 w-4 flex-none" }),
|
|
5028
|
+
/* @__PURE__ */ jsx("span", { className: "", children: child.title })
|
|
5029
|
+
]
|
|
5030
|
+
}
|
|
5031
|
+
) }, child.websitePath);
|
|
5032
|
+
}) }) })
|
|
5033
|
+
] }, node.websitePath) }, `menu-${node.websitePath}`)
|
|
5034
|
+
},
|
|
5035
|
+
node.websitePath
|
|
5036
|
+
) : /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(
|
|
5026
5037
|
Link2,
|
|
5027
5038
|
{
|
|
5028
5039
|
href: node.websitePath,
|
|
5040
|
+
onClick: onNavigateLeaf,
|
|
5029
5041
|
className: `group/row relative flex items-center gap-2 py-1.5 pl-3 pr-2 rounded-md text-sm transition-colors hover:bg-accent ${isActive ? "bg-accent font-medium text-foreground before:absolute before:inset-y-1 before:left-0 before:w-0.5 before:rounded-full before:bg-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
5030
5042
|
children: [
|
|
5031
5043
|
/* @__PURE__ */ jsx(FileTextIcon, { className: "h-4 w-4 flex-none" }),
|
|
@@ -5035,7 +5047,34 @@ function SidebarNavigation2({
|
|
|
5035
5047
|
) }, node.websitePath) }, `menu-${node.websitePath}`);
|
|
5036
5048
|
}) }) });
|
|
5037
5049
|
}
|
|
5050
|
+
var open = false;
|
|
5051
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
5052
|
+
function emit() {
|
|
5053
|
+
for (const listener of listeners) listener();
|
|
5054
|
+
}
|
|
5055
|
+
function setMobileMenuOpen(value) {
|
|
5056
|
+
if (open === value) return;
|
|
5057
|
+
open = value;
|
|
5058
|
+
emit();
|
|
5059
|
+
}
|
|
5060
|
+
function subscribe(listener) {
|
|
5061
|
+
listeners.add(listener);
|
|
5062
|
+
return () => {
|
|
5063
|
+
listeners.delete(listener);
|
|
5064
|
+
};
|
|
5065
|
+
}
|
|
5066
|
+
function getSnapshot() {
|
|
5067
|
+
return open;
|
|
5068
|
+
}
|
|
5069
|
+
function getServerSnapshot() {
|
|
5070
|
+
return false;
|
|
5071
|
+
}
|
|
5072
|
+
function useMobileMenuOpen() {
|
|
5073
|
+
const value = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
5074
|
+
return [value, setMobileMenuOpen];
|
|
5075
|
+
}
|
|
5038
5076
|
function MobileMenu2({ pageData, translations: translations2 = {} }) {
|
|
5077
|
+
const [open2, setOpen] = useMobileMenuOpen();
|
|
5039
5078
|
if (!pageData) {
|
|
5040
5079
|
return null;
|
|
5041
5080
|
}
|
|
@@ -5045,7 +5084,7 @@ function MobileMenu2({ pageData, translations: translations2 = {} }) {
|
|
|
5045
5084
|
mobileMenuDescription = "Mobile navigation menu"
|
|
5046
5085
|
} = translations2;
|
|
5047
5086
|
const { sidebar, navigation: nav, computed } = pageData;
|
|
5048
|
-
return /* @__PURE__ */ jsx("div", { className: "lg:hidden", children: /* @__PURE__ */ jsxs(Drawer, { direction: "right", children: [
|
|
5087
|
+
return /* @__PURE__ */ jsx("div", { className: "lg:hidden", children: /* @__PURE__ */ jsxs(Drawer, { direction: "right", open: open2, onOpenChange: setOpen, children: [
|
|
5049
5088
|
/* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "icon", className: "h-9 w-9", children: [
|
|
5050
5089
|
/* @__PURE__ */ jsx(Menu, { className: "h-4 w-4" }),
|
|
5051
5090
|
/* @__PURE__ */ jsx("span", { className: "sr-only", children: openMobileMenu })
|
|
@@ -5080,7 +5119,8 @@ function MobileMenu2({ pageData, translations: translations2 = {} }) {
|
|
|
5080
5119
|
{
|
|
5081
5120
|
nodes: sidebar.items,
|
|
5082
5121
|
currentPath: `/${computed.lang}/docs/${computed.path}`,
|
|
5083
|
-
language: computed.lang
|
|
5122
|
+
language: computed.lang,
|
|
5123
|
+
onNavigateLeaf: () => setOpen(false)
|
|
5084
5124
|
}
|
|
5085
5125
|
)
|
|
5086
5126
|
] })
|
|
@@ -5455,7 +5495,7 @@ function useMediaQuery(query) {
|
|
|
5455
5495
|
return value;
|
|
5456
5496
|
}
|
|
5457
5497
|
function BreadcrumbToggle({ overflowItems, className }) {
|
|
5458
|
-
const [
|
|
5498
|
+
const [open2, setOpen] = React8.useState(false);
|
|
5459
5499
|
const isDesktop = useMediaQuery("(min-width: 768px)");
|
|
5460
5500
|
const handleOverflowItemClick = useCallback(() => {
|
|
5461
5501
|
setOpen(false);
|
|
@@ -5463,7 +5503,7 @@ function BreadcrumbToggle({ overflowItems, className }) {
|
|
|
5463
5503
|
if (overflowItems.length === 0) {
|
|
5464
5504
|
return null;
|
|
5465
5505
|
}
|
|
5466
|
-
return /* @__PURE__ */ jsx(BreadcrumbItem, { className, children: isDesktop ? /* @__PURE__ */ jsxs(DropdownMenu, { open, onOpenChange: setOpen, children: [
|
|
5506
|
+
return /* @__PURE__ */ jsx(BreadcrumbItem, { className, children: isDesktop ? /* @__PURE__ */ jsxs(DropdownMenu, { open: open2, onOpenChange: setOpen, children: [
|
|
5467
5507
|
/* @__PURE__ */ jsxs(
|
|
5468
5508
|
DropdownMenuTrigger,
|
|
5469
5509
|
{
|
|
@@ -5484,7 +5524,7 @@ function BreadcrumbToggle({ overflowItems, className }) {
|
|
|
5484
5524
|
children: item.label
|
|
5485
5525
|
}
|
|
5486
5526
|
) }) }, index)) })
|
|
5487
|
-
] }) : /* @__PURE__ */ jsxs(Drawer, { open, onOpenChange: setOpen, children: [
|
|
5527
|
+
] }) : /* @__PURE__ */ jsxs(Drawer, { open: open2, onOpenChange: setOpen, children: [
|
|
5488
5528
|
/* @__PURE__ */ jsx(DrawerTrigger, { "aria-label": "Show more breadcrumb items", children: /* @__PURE__ */ jsx(BreadcrumbEllipsis, { className: "h-4 w-4" }) }),
|
|
5489
5529
|
/* @__PURE__ */ jsxs(DrawerContent, { children: [
|
|
5490
5530
|
/* @__PURE__ */ jsx("div", { className: "grid gap-1 p-4 overflow-y-auto", children: overflowItems.map((item, index) => /* @__PURE__ */ jsx(
|
|
@@ -5591,6 +5631,27 @@ function FolderCards({ nodes }) {
|
|
|
5591
5631
|
node.websitePath
|
|
5592
5632
|
)) });
|
|
5593
5633
|
}
|
|
5634
|
+
function resolveInternalDocHref(href, baseDir, locale) {
|
|
5635
|
+
if (!href || baseDir === void 0 || !locale) return null;
|
|
5636
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || href.startsWith("#") || href.startsWith("/")) {
|
|
5637
|
+
return null;
|
|
5638
|
+
}
|
|
5639
|
+
const marker = href.search(/[#?]/);
|
|
5640
|
+
const pathPart = marker === -1 ? href : href.slice(0, marker);
|
|
5641
|
+
const suffix = marker === -1 ? "" : href.slice(marker);
|
|
5642
|
+
if (!/\.md$/i.test(pathPart)) return null;
|
|
5643
|
+
const segments = baseDir.split("/").filter(Boolean);
|
|
5644
|
+
for (const raw of pathPart.split("/")) {
|
|
5645
|
+
if (raw === "" || raw === ".") continue;
|
|
5646
|
+
if (raw === "..") {
|
|
5647
|
+
if (segments.length) segments.pop();
|
|
5648
|
+
continue;
|
|
5649
|
+
}
|
|
5650
|
+
segments.push(raw);
|
|
5651
|
+
}
|
|
5652
|
+
const resolved = segments.join("/").replace(/\/index\.md$/i, "").replace(/\.md$/i, "");
|
|
5653
|
+
return resolved ? `/${locale}/docs/${resolved}${suffix}` : `/${locale}/docs${suffix}`;
|
|
5654
|
+
}
|
|
5594
5655
|
function CodeBlock({ children, ...props }) {
|
|
5595
5656
|
const preRef = useRef(null);
|
|
5596
5657
|
const [copied, setCopied] = useState(false);
|
|
@@ -5617,10 +5678,26 @@ function CodeBlock({ children, ...props }) {
|
|
|
5617
5678
|
/* @__PURE__ */ jsx("pre", { ref: preRef, ...props, children })
|
|
5618
5679
|
] });
|
|
5619
5680
|
}
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5681
|
+
function makeAnchor(baseDir, locale) {
|
|
5682
|
+
return function Anchor({
|
|
5683
|
+
href,
|
|
5684
|
+
children,
|
|
5685
|
+
...props
|
|
5686
|
+
}) {
|
|
5687
|
+
const internal = resolveInternalDocHref(href, baseDir, locale);
|
|
5688
|
+
if (internal) {
|
|
5689
|
+
return /* @__PURE__ */ jsx(Link2, { href: internal, children });
|
|
5690
|
+
}
|
|
5691
|
+
return /* @__PURE__ */ jsx("a", { href, ...props, children });
|
|
5692
|
+
};
|
|
5693
|
+
}
|
|
5694
|
+
function makeComponents(baseDir, locale) {
|
|
5695
|
+
return {
|
|
5696
|
+
h1: () => null,
|
|
5697
|
+
pre: CodeBlock,
|
|
5698
|
+
a: makeAnchor(baseDir, locale)
|
|
5699
|
+
};
|
|
5700
|
+
}
|
|
5624
5701
|
var remarkPlugins = [remarkLint, remarkGfm, remarkFrontmatter];
|
|
5625
5702
|
var rehypePlugins = [
|
|
5626
5703
|
rehypeSanitize,
|
|
@@ -5637,10 +5714,22 @@ var rehypePlugins = [
|
|
|
5637
5714
|
rehypeExternalLinks,
|
|
5638
5715
|
rehypeHighlight
|
|
5639
5716
|
];
|
|
5640
|
-
function Markdown({
|
|
5641
|
-
|
|
5717
|
+
function Markdown({
|
|
5718
|
+
markdown,
|
|
5719
|
+
baseDir,
|
|
5720
|
+
locale
|
|
5721
|
+
}) {
|
|
5722
|
+
return /* @__PURE__ */ jsx(
|
|
5723
|
+
ReactMarkdown,
|
|
5724
|
+
{
|
|
5725
|
+
remarkPlugins,
|
|
5726
|
+
rehypePlugins,
|
|
5727
|
+
components: makeComponents(baseDir, locale),
|
|
5728
|
+
children: markdown
|
|
5729
|
+
}
|
|
5730
|
+
);
|
|
5642
5731
|
}
|
|
5643
|
-
function Tabs({ tabs }) {
|
|
5732
|
+
function Tabs({ tabs, baseDir, locale }) {
|
|
5644
5733
|
const [active, setActive] = useState(0);
|
|
5645
5734
|
return /* @__PURE__ */ jsxs("div", { className: "cl-tabs not-prose", children: [
|
|
5646
5735
|
/* @__PURE__ */ jsx("div", { className: "cl-tabs-list", role: "tablist", children: tabs.map((t, i) => /* @__PURE__ */ jsx(
|
|
@@ -5655,7 +5744,7 @@ function Tabs({ tabs }) {
|
|
|
5655
5744
|
},
|
|
5656
5745
|
i
|
|
5657
5746
|
)) }),
|
|
5658
|
-
/* @__PURE__ */ jsx("div", { className: "cl-tabs-panel prose prose-md max-w-none dark:prose-invert", children: /* @__PURE__ */ jsx(Markdown, { markdown: tabs[active]?.content ?? "" }) })
|
|
5747
|
+
/* @__PURE__ */ jsx("div", { className: "cl-tabs-panel prose prose-md max-w-none dark:prose-invert", children: /* @__PURE__ */ jsx(Markdown, { markdown: tabs[active]?.content ?? "", baseDir, locale }) })
|
|
5659
5748
|
] });
|
|
5660
5749
|
}
|
|
5661
5750
|
function parseSegments(md) {
|
|
@@ -5679,10 +5768,10 @@ function parseTabs(block) {
|
|
|
5679
5768
|
}
|
|
5680
5769
|
return tabs.length ? tabs : [{ title: "Tab", content: block }];
|
|
5681
5770
|
}
|
|
5682
|
-
function MarkdownRenderer({ markdown, className = "" }) {
|
|
5771
|
+
function MarkdownRenderer({ markdown, className = "", baseDir, locale }) {
|
|
5683
5772
|
const segments = markdown.includes("<!-- tabs") ? parseSegments(markdown) : [{ type: "md", content: markdown }];
|
|
5684
5773
|
return /* @__PURE__ */ jsx("article", { className: `cl-content-in prose prose-md max-w-none dark:prose-invert ${className}`, children: segments.map(
|
|
5685
|
-
(s, i) => s.type === "tabs" ? /* @__PURE__ */ jsx(Tabs, { tabs: s.tabs }, i) : /* @__PURE__ */ jsx(Markdown, { markdown: s.content }, i)
|
|
5774
|
+
(s, i) => s.type === "tabs" ? /* @__PURE__ */ jsx(Tabs, { tabs: s.tabs, baseDir, locale }, i) : /* @__PURE__ */ jsx(Markdown, { markdown: s.content, baseDir, locale }, i)
|
|
5686
5775
|
) });
|
|
5687
5776
|
}
|
|
5688
5777
|
function ChatGPTIcon({ className }) {
|