@takazudo/zudo-doc 0.1.0
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/LICENSE +21 -0
- package/README.md +18 -0
- package/dist/body-foot-util/body-foot-util-area.d.ts +55 -0
- package/dist/body-foot-util/body-foot-util-area.js +71 -0
- package/dist/body-foot-util/edit-link.d.ts +45 -0
- package/dist/body-foot-util/edit-link.js +42 -0
- package/dist/body-foot-util/index.d.ts +3 -0
- package/dist/body-foot-util/index.js +11 -0
- package/dist/breadcrumb/breadcrumb.d.ts +57 -0
- package/dist/breadcrumb/breadcrumb.js +113 -0
- package/dist/breadcrumb/find-path.d.ts +16 -0
- package/dist/breadcrumb/find-path.js +13 -0
- package/dist/breadcrumb/index.d.ts +4 -0
- package/dist/breadcrumb/index.js +7 -0
- package/dist/breadcrumb/types.d.ts +32 -0
- package/dist/breadcrumb/types.js +0 -0
- package/dist/code-syntax/code-block-enhancer-script.d.ts +3 -0
- package/dist/code-syntax/code-block-enhancer-script.js +165 -0
- package/dist/code-syntax/code-block-enhancer.d.ts +22 -0
- package/dist/code-syntax/code-block-enhancer.js +13 -0
- package/dist/code-syntax/index.d.ts +8 -0
- package/dist/code-syntax/index.js +29 -0
- package/dist/code-syntax/mermaid-init-script.d.ts +51 -0
- package/dist/code-syntax/mermaid-init-script.js +225 -0
- package/dist/code-syntax/mermaid-init.d.ts +48 -0
- package/dist/code-syntax/mermaid-init.js +14 -0
- package/dist/code-syntax/tabs-init-script.d.ts +3 -0
- package/dist/code-syntax/tabs-init-script.js +106 -0
- package/dist/code-syntax/tabs-init.d.ts +24 -0
- package/dist/code-syntax/tabs-init.js +10 -0
- package/dist/code-syntax/tabs.d.ts +36 -0
- package/dist/code-syntax/tabs.js +62 -0
- package/dist/content/component-map.d.ts +51 -0
- package/dist/content/component-map.js +29 -0
- package/dist/content/content-blockquote.d.ts +11 -0
- package/dist/content/content-blockquote.js +14 -0
- package/dist/content/content-code.d.ts +26 -0
- package/dist/content/content-code.js +39 -0
- package/dist/content/content-link.d.ts +12 -0
- package/dist/content/content-link.js +43 -0
- package/dist/content/content-ol.d.ts +11 -0
- package/dist/content/content-ol.js +15 -0
- package/dist/content/content-paragraph.d.ts +10 -0
- package/dist/content/content-paragraph.js +7 -0
- package/dist/content/content-strong.d.ts +11 -0
- package/dist/content/content-strong.js +14 -0
- package/dist/content/content-table.d.ts +11 -0
- package/dist/content/content-table.js +14 -0
- package/dist/content/content-ul.d.ts +11 -0
- package/dist/content/content-ul.js +15 -0
- package/dist/content/heading-h2.d.ts +14 -0
- package/dist/content/heading-h2.js +18 -0
- package/dist/content/heading-h3.d.ts +14 -0
- package/dist/content/heading-h3.js +18 -0
- package/dist/content/heading-h4.d.ts +14 -0
- package/dist/content/heading-h4.js +18 -0
- package/dist/content/index.d.ts +13 -0
- package/dist/content/index.js +27 -0
- package/dist/details/details.d.ts +26 -0
- package/dist/details/details.js +10 -0
- package/dist/details/index.d.ts +2 -0
- package/dist/details/index.js +4 -0
- package/dist/doclayout/anchors.d.ts +55 -0
- package/dist/doclayout/anchors.js +42 -0
- package/dist/doclayout/doc-layout-with-defaults.d.ts +83 -0
- package/dist/doclayout/doc-layout-with-defaults.js +159 -0
- package/dist/doclayout/doc-layout.d.ts +121 -0
- package/dist/doclayout/doc-layout.js +89 -0
- package/dist/doclayout/index.d.ts +6 -0
- package/dist/doclayout/index.js +17 -0
- package/dist/footer/footer.d.ts +42 -0
- package/dist/footer/footer.js +79 -0
- package/dist/footer/index.d.ts +3 -0
- package/dist/footer/index.js +4 -0
- package/dist/footer/types.d.ts +58 -0
- package/dist/footer/types.js +0 -0
- package/dist/head/doc-head.d.ts +33 -0
- package/dist/head/doc-head.js +90 -0
- package/dist/head/index.d.ts +5 -0
- package/dist/head/index.js +8 -0
- package/dist/head/og-tags.d.ts +25 -0
- package/dist/head/og-tags.js +16 -0
- package/dist/head/twitter-card.d.ts +21 -0
- package/dist/head/twitter-card.js +14 -0
- package/dist/head/types.d.ts +83 -0
- package/dist/head/types.js +0 -0
- package/dist/header/header.d.ts +158 -0
- package/dist/header/header.js +367 -0
- package/dist/header/index.d.ts +6 -0
- package/dist/header/index.js +18 -0
- package/dist/header/nav-active.d.ts +39 -0
- package/dist/header/nav-active.js +24 -0
- package/dist/header/nav-overflow-script.d.ts +3 -0
- package/dist/header/nav-overflow-script.js +169 -0
- package/dist/header/right-items.d.ts +38 -0
- package/dist/header/right-items.js +30 -0
- package/dist/header/types.d.ts +40 -0
- package/dist/header/types.js +0 -0
- package/dist/html-preview-wrapper/dedent.d.ts +10 -0
- package/dist/html-preview-wrapper/dedent.js +16 -0
- package/dist/html-preview-wrapper/highlighted-code.d.ts +18 -0
- package/dist/html-preview-wrapper/highlighted-code.js +53 -0
- package/dist/html-preview-wrapper/html-preview-wrapper.d.ts +60 -0
- package/dist/html-preview-wrapper/html-preview-wrapper.js +36 -0
- package/dist/html-preview-wrapper/html-preview.d.ts +35 -0
- package/dist/html-preview-wrapper/html-preview.js +75 -0
- package/dist/html-preview-wrapper/index.d.ts +5 -0
- package/dist/html-preview-wrapper/index.js +12 -0
- package/dist/html-preview-wrapper/preflight.d.ts +13 -0
- package/dist/html-preview-wrapper/preflight.js +108 -0
- package/dist/html-preview-wrapper/preview-base.d.ts +29 -0
- package/dist/html-preview-wrapper/preview-base.js +127 -0
- package/dist/i18n-version/index.d.ts +5 -0
- package/dist/i18n-version/index.js +14 -0
- package/dist/i18n-version/language-switcher.d.ts +24 -0
- package/dist/i18n-version/language-switcher.js +25 -0
- package/dist/i18n-version/types.d.ts +43 -0
- package/dist/i18n-version/types.js +0 -0
- package/dist/i18n-version/version-banner.d.ts +30 -0
- package/dist/i18n-version/version-banner.js +21 -0
- package/dist/i18n-version/version-switcher.d.ts +112 -0
- package/dist/i18n-version/version-switcher.js +157 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +0 -0
- package/dist/integrations/claude-resources/escape-for-mdx.d.ts +8 -0
- package/dist/integrations/claude-resources/escape-for-mdx.js +131 -0
- package/dist/integrations/claude-resources/generate.d.ts +13 -0
- package/dist/integrations/claude-resources/generate.js +404 -0
- package/dist/integrations/claude-resources/index.d.ts +46 -0
- package/dist/integrations/claude-resources/index.js +24 -0
- package/dist/integrations/doc-history/index.d.ts +137 -0
- package/dist/integrations/doc-history/index.js +138 -0
- package/dist/integrations/doc-history/pre-build.d.ts +58 -0
- package/dist/integrations/doc-history/pre-build.js +67 -0
- package/dist/integrations/llms-txt/dev-middleware.d.ts +40 -0
- package/dist/integrations/llms-txt/dev-middleware.js +76 -0
- package/dist/integrations/llms-txt/emit.d.ts +22 -0
- package/dist/integrations/llms-txt/emit.js +55 -0
- package/dist/integrations/llms-txt/generate.d.ts +26 -0
- package/dist/integrations/llms-txt/generate.js +36 -0
- package/dist/integrations/llms-txt/index.d.ts +7 -0
- package/dist/integrations/llms-txt/index.js +27 -0
- package/dist/integrations/llms-txt/load.d.ts +51 -0
- package/dist/integrations/llms-txt/load.js +83 -0
- package/dist/integrations/llms-txt/strip.d.ts +22 -0
- package/dist/integrations/llms-txt/strip.js +10 -0
- package/dist/integrations/llms-txt/types.d.ts +145 -0
- package/dist/integrations/llms-txt/types.js +0 -0
- package/dist/integrations/search-index/build-emitter.d.ts +30 -0
- package/dist/integrations/search-index/build-emitter.js +15 -0
- package/dist/integrations/search-index/collect.d.ts +12 -0
- package/dist/integrations/search-index/collect.js +48 -0
- package/dist/integrations/search-index/content-files.d.ts +32 -0
- package/dist/integrations/search-index/content-files.js +50 -0
- package/dist/integrations/search-index/dev-middleware.d.ts +16 -0
- package/dist/integrations/search-index/dev-middleware.js +30 -0
- package/dist/integrations/search-index/index.d.ts +5 -0
- package/dist/integrations/search-index/index.js +14 -0
- package/dist/integrations/search-index/types.d.ts +38 -0
- package/dist/integrations/search-index/types.js +6 -0
- package/dist/metainfo/doc-metainfo.d.ts +50 -0
- package/dist/metainfo/doc-metainfo.js +107 -0
- package/dist/metainfo/doc-tags.d.ts +66 -0
- package/dist/metainfo/doc-tags.js +53 -0
- package/dist/metainfo/frontmatter-preview.d.ts +95 -0
- package/dist/metainfo/frontmatter-preview.js +55 -0
- package/dist/metainfo/index.d.ts +4 -0
- package/dist/metainfo/index.js +28 -0
- package/dist/nav-indexing/category-nav.d.ts +28 -0
- package/dist/nav-indexing/category-nav.js +41 -0
- package/dist/nav-indexing/category-tree-nav.d.ts +27 -0
- package/dist/nav-indexing/category-tree-nav.js +49 -0
- package/dist/nav-indexing/doc-card-grid.d.ts +38 -0
- package/dist/nav-indexing/doc-card-grid.js +40 -0
- package/dist/nav-indexing/docs-sitemap.d.ts +25 -0
- package/dist/nav-indexing/docs-sitemap.js +40 -0
- package/dist/nav-indexing/index.d.ts +10 -0
- package/dist/nav-indexing/index.js +18 -0
- package/dist/nav-indexing/nav-card-grid.d.ts +31 -0
- package/dist/nav-indexing/nav-card-grid.js +43 -0
- package/dist/nav-indexing/site-tree-nav-demo.d.ts +39 -0
- package/dist/nav-indexing/site-tree-nav-demo.js +65 -0
- package/dist/nav-indexing/tag-nav.d.ts +38 -0
- package/dist/nav-indexing/tag-nav.js +96 -0
- package/dist/nav-indexing/types.d.ts +95 -0
- package/dist/nav-indexing/types.js +0 -0
- package/dist/nav-indexing/versions-page-content.d.ts +29 -0
- package/dist/nav-indexing/versions-page-content.js +76 -0
- package/dist/page-loading/index.d.ts +2 -0
- package/dist/page-loading/index.js +10 -0
- package/dist/page-loading/page-loading-overlay.d.ts +35 -0
- package/dist/page-loading/page-loading-overlay.js +50 -0
- package/dist/sidebar/index.d.ts +3 -0
- package/dist/sidebar/index.js +4 -0
- package/dist/sidebar/sidebar.d.ts +54 -0
- package/dist/sidebar/sidebar.js +35 -0
- package/dist/sidebar/types.d.ts +71 -0
- package/dist/sidebar/types.js +0 -0
- package/dist/sidebar-resizer/index.d.ts +14 -0
- package/dist/sidebar-resizer/index.js +165 -0
- package/dist/sidebar-resizer/sidebar-resizer-init.d.ts +20 -0
- package/dist/sidebar-resizer/sidebar-resizer-init.js +119 -0
- package/dist/sidebar-tree/build-tree.d.ts +43 -0
- package/dist/sidebar-tree/build-tree.js +127 -0
- package/dist/sidebar-tree/category-meta.d.ts +19 -0
- package/dist/sidebar-tree/category-meta.js +63 -0
- package/dist/sidebar-tree/index.d.ts +3 -0
- package/dist/sidebar-tree/index.js +13 -0
- package/dist/sidebar-tree/types.d.ts +120 -0
- package/dist/sidebar-tree/types.js +0 -0
- package/dist/tab-item/index.d.ts +2 -0
- package/dist/tab-item/index.js +5 -0
- package/dist/tab-item/tab-item.d.ts +38 -0
- package/dist/tab-item/tab-item.js +25 -0
- package/dist/theme/color-scheme-provider.d.ts +32 -0
- package/dist/theme/color-scheme-provider.js +43 -0
- package/dist/theme/color-tweak-export-modal.d.ts +20 -0
- package/dist/theme/color-tweak-export-modal.js +138 -0
- package/dist/theme/design-token-serde.d.ts +136 -0
- package/dist/theme/design-token-serde.js +254 -0
- package/dist/theme/design-token-tweak-panel.d.ts +11 -0
- package/dist/theme/design-token-tweak-panel.js +10 -0
- package/dist/theme/design-token-types.d.ts +19 -0
- package/dist/theme/design-token-types.js +6 -0
- package/dist/theme/iframe-bridge.d.ts +44 -0
- package/dist/theme/iframe-bridge.js +70 -0
- package/dist/theme/index.d.ts +9 -0
- package/dist/theme/index.js +42 -0
- package/dist/theme/theme-toggle.d.ts +17 -0
- package/dist/theme/theme-toggle.js +91 -0
- package/dist/toc/cx.d.ts +16 -0
- package/dist/toc/cx.js +22 -0
- package/dist/toc/index.d.ts +5 -0
- package/dist/toc/index.js +9 -0
- package/dist/toc/mobile-toc.d.ts +46 -0
- package/dist/toc/mobile-toc.js +88 -0
- package/dist/toc/smart-break.d.ts +27 -0
- package/dist/toc/smart-break.js +36 -0
- package/dist/toc/toc-title.d.ts +10 -0
- package/dist/toc/toc-title.js +14 -0
- package/dist/toc/toc.d.ts +60 -0
- package/dist/toc/toc.js +56 -0
- package/dist/toc/types.d.ts +23 -0
- package/dist/toc/types.js +0 -0
- package/dist/toc/use-active-heading.d.ts +30 -0
- package/dist/toc/use-active-heading.js +106 -0
- package/dist/transitions/index.d.ts +1 -0
- package/dist/transitions/index.js +12 -0
- package/dist/transitions/page-events.d.ts +41 -0
- package/dist/transitions/page-events.js +20 -0
- package/dist/url-normalizer/index.d.ts +1 -0
- package/dist/url-normalizer/index.js +6 -0
- package/dist/url-normalizer/normalize.d.ts +104 -0
- package/dist/url-normalizer/normalize.js +22 -0
- package/package.json +186 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
AFTER_NAVIGATE_EVENT,
|
|
4
|
+
BEFORE_NAVIGATE_EVENT
|
|
5
|
+
} from "../transitions/page-events.js";
|
|
6
|
+
const PAGE_LOADING_OVERLAY_ID = "page-loading-overlay";
|
|
7
|
+
function buildPageLoadingOverlayBootstrap(overlayId) {
|
|
8
|
+
const id = JSON.stringify(overlayId);
|
|
9
|
+
const before = JSON.stringify(BEFORE_NAVIGATE_EVENT);
|
|
10
|
+
const after = JSON.stringify(AFTER_NAVIGATE_EVENT);
|
|
11
|
+
return `(function(){
|
|
12
|
+
var id=${id};
|
|
13
|
+
function show(){var el=document.getElementById(id);if(!el)return;el.setAttribute("data-visible","");el.setAttribute("aria-hidden","false");}
|
|
14
|
+
function hide(){var el=document.getElementById(id);if(!el)return;el.removeAttribute("data-visible");el.setAttribute("aria-hidden","true");}
|
|
15
|
+
function setPending(ev){document.querySelectorAll("[data-zd-nav-pending]").forEach(function(el){el.removeAttribute("data-zd-nav-pending");});var src=ev&&ev.sourceElement;if(src&&src instanceof Element)src.setAttribute("data-zd-nav-pending","");}
|
|
16
|
+
function clearPending(){document.querySelectorAll("[data-zd-nav-pending]").forEach(function(el){el.removeAttribute("data-zd-nav-pending");});}
|
|
17
|
+
document.addEventListener(${before},show);
|
|
18
|
+
document.addEventListener(${after},hide);
|
|
19
|
+
document.addEventListener(${before},setPending);
|
|
20
|
+
document.addEventListener(${after},clearPending);
|
|
21
|
+
})();`;
|
|
22
|
+
}
|
|
23
|
+
function PageLoadingOverlay({
|
|
24
|
+
id = PAGE_LOADING_OVERLAY_ID
|
|
25
|
+
} = {}) {
|
|
26
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
id,
|
|
31
|
+
class: "page-loading-overlay",
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
children: /* @__PURE__ */ jsx("span", { class: "page-loading-spinner" })
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
"script",
|
|
38
|
+
{
|
|
39
|
+
dangerouslySetInnerHTML: {
|
|
40
|
+
__html: buildPageLoadingOverlayBootstrap(id)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
PAGE_LOADING_OVERLAY_ID,
|
|
48
|
+
buildPageLoadingOverlayBootstrap,
|
|
49
|
+
PageLoadingOverlay as default
|
|
50
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FunctionComponent, ComponentChildren, VNode } from 'preact';
|
|
2
|
+
import { SidebarTreeIslandProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
/** @jsxRuntime automatic */
|
|
5
|
+
/** @jsxImportSource preact */
|
|
6
|
+
|
|
7
|
+
interface SidebarProps extends SidebarTreeIslandProps {
|
|
8
|
+
/**
|
|
9
|
+
* The host's SidebarTree component. When present, the shell renders
|
|
10
|
+
* `<TreeComponent {...islandProps} />` with the typed props below.
|
|
11
|
+
* Mutually exclusive with `children`: prefer this form so v2 owns the
|
|
12
|
+
* prop forwarding contract.
|
|
13
|
+
*/
|
|
14
|
+
treeComponent?: FunctionComponent<SidebarTreeIslandProps>;
|
|
15
|
+
/**
|
|
16
|
+
* Pre-rendered tree content — falls back to this when
|
|
17
|
+
* `treeComponent` is omitted. Useful for tests and for layouts that
|
|
18
|
+
* compose the tree separately (e.g. inside an Astro `.astro` wrapper
|
|
19
|
+
* that needs `client:load` on the actual island element).
|
|
20
|
+
*/
|
|
21
|
+
children?: ComponentChildren;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Sidebar shell — typed wrapper around the SidebarTree island.
|
|
25
|
+
*
|
|
26
|
+
* Two usage shapes (matching the breadcrumb shell's pattern):
|
|
27
|
+
*
|
|
28
|
+
* 1. Pass `treeComponent` plus the data props (`nodes`,
|
|
29
|
+
* `rootMenuItems`, `localeLinks`, …). The shell forwards them all
|
|
30
|
+
* to the supplied component.
|
|
31
|
+
*
|
|
32
|
+
* 2. Pass `children` (e.g. a pre-instantiated `<SidebarTree
|
|
33
|
+
* client:load … />` from an Astro wrapper). The shell renders
|
|
34
|
+
* them as-is — the typed island props are then unused but kept on
|
|
35
|
+
* the type signature so call-sites stay self-documenting.
|
|
36
|
+
*
|
|
37
|
+
* **The caller is responsible for wrapping this in `<Island when="load">`**
|
|
38
|
+
* so the SSG output emits the `data-zfb-island="Sidebar"` hydration
|
|
39
|
+
* marker around the rendered tree. `<DocLayoutWithDefaults>` does this
|
|
40
|
+
* for you; consumers who render `<Sidebar>` outside the default layout
|
|
41
|
+
* (e.g. via the `sidebarOverride` prop or in a custom layout) must
|
|
42
|
+
* apply the wrapper themselves — otherwise no hydration marker is
|
|
43
|
+
* emitted, and the runtime walks past the SSR'd tree without claiming
|
|
44
|
+
* it as an island. Either way the actual user-facing interactivity
|
|
45
|
+
* comes from the `treeComponent`'s own island registration; the
|
|
46
|
+
* `<Island>` wrapper here exists so the shell can host data-only
|
|
47
|
+
* variants in the future without losing the marker contract.
|
|
48
|
+
*/
|
|
49
|
+
declare function Sidebar(props: SidebarProps): VNode | null;
|
|
50
|
+
declare namespace Sidebar {
|
|
51
|
+
var displayName: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { Sidebar, type SidebarProps };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx } from "preact/jsx-runtime";
|
|
3
|
+
function Sidebar(props) {
|
|
4
|
+
const {
|
|
5
|
+
treeComponent: TreeComponent,
|
|
6
|
+
children,
|
|
7
|
+
nodes,
|
|
8
|
+
currentSlug,
|
|
9
|
+
rootMenuItems,
|
|
10
|
+
backToMenuLabel,
|
|
11
|
+
localeLinks,
|
|
12
|
+
themeDefaultMode
|
|
13
|
+
} = props;
|
|
14
|
+
if (TreeComponent) {
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
TreeComponent,
|
|
17
|
+
{
|
|
18
|
+
nodes,
|
|
19
|
+
currentSlug,
|
|
20
|
+
rootMenuItems,
|
|
21
|
+
backToMenuLabel,
|
|
22
|
+
localeLinks,
|
|
23
|
+
themeDefaultMode
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
if (children !== void 0 && children !== null) {
|
|
28
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
Sidebar.displayName = "Sidebar";
|
|
33
|
+
export {
|
|
34
|
+
Sidebar
|
|
35
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for the framework-agnostic sidebar shell.
|
|
3
|
+
*
|
|
4
|
+
* The original Astro `sidebar.astro` mixed three concerns:
|
|
5
|
+
* 1. Building `rootMenuItems` from `settings.headerNav` (with i18n
|
|
6
|
+
* label resolution and version-aware hrefs).
|
|
7
|
+
* 2. Building the doc tree via `loadLocaleDocs` +
|
|
8
|
+
* `buildSidebarForSection`, then optionally remapping hrefs to
|
|
9
|
+
* versioned paths.
|
|
10
|
+
* 3. Rendering a `<SidebarTree client:load .../>` Preact island.
|
|
11
|
+
*
|
|
12
|
+
* Concerns (1) and (2) depend on host-only helpers that v2 must not
|
|
13
|
+
* reach into. The v2 shell exists to:
|
|
14
|
+
* - publish the prop shape so the host's data prep code can be
|
|
15
|
+
* typed against a v2-owned interface, and
|
|
16
|
+
* - render whatever the host hands in (typically the project's
|
|
17
|
+
* `<SidebarTree client:load .../>` island) inside a typed wrapper.
|
|
18
|
+
*
|
|
19
|
+
* The structural types here mirror `src/utils/docs.ts` (`NavNode`) and
|
|
20
|
+
* `src/types/locale.ts` (`LocaleLink`) so the host can keep using its
|
|
21
|
+
* existing data-prep pipeline without re-mapping fields.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* One node in the navigation tree the SidebarTree island renders.
|
|
25
|
+
* Matches `NavNode` in the host project's `src/utils/docs.ts`.
|
|
26
|
+
*/
|
|
27
|
+
interface SidebarNavNode {
|
|
28
|
+
slug: string;
|
|
29
|
+
label: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
position: number;
|
|
32
|
+
href?: string;
|
|
33
|
+
hasPage: boolean;
|
|
34
|
+
children: SidebarNavNode[];
|
|
35
|
+
sortOrder?: "asc" | "desc";
|
|
36
|
+
collapsed?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Item in the root-level "Docusaurus-style" menu shown above the
|
|
40
|
+
* doc tree on mobile / inside the back-to-menu view.
|
|
41
|
+
*/
|
|
42
|
+
interface SidebarRootMenuItem {
|
|
43
|
+
label: string;
|
|
44
|
+
href: string;
|
|
45
|
+
children?: SidebarRootMenuItem[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Locale switcher link rendered inside the mobile sidebar footer.
|
|
49
|
+
* Matches `LocaleLink` in the host project's `src/types/locale.ts`.
|
|
50
|
+
*/
|
|
51
|
+
interface SidebarLocaleLink {
|
|
52
|
+
code: string;
|
|
53
|
+
label: string;
|
|
54
|
+
href: string;
|
|
55
|
+
active: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Props the SidebarTree island consumes. The shell forwards these
|
|
59
|
+
* to whichever component the host plugs in via {@link SidebarProps.treeComponent}
|
|
60
|
+
* (or to nothing, when the host renders its own tree as `children`).
|
|
61
|
+
*/
|
|
62
|
+
interface SidebarTreeIslandProps {
|
|
63
|
+
nodes: SidebarNavNode[];
|
|
64
|
+
currentSlug?: string;
|
|
65
|
+
rootMenuItems?: SidebarRootMenuItem[];
|
|
66
|
+
backToMenuLabel?: string;
|
|
67
|
+
localeLinks?: SidebarLocaleLink[];
|
|
68
|
+
themeDefaultMode?: "light" | "dark";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type { SidebarLocaleLink, SidebarNavNode, SidebarRootMenuItem, SidebarTreeIslandProps };
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { SIDEBAR_RESIZER_INIT_SCRIPT, SidebarResizerInit } from './sidebar-resizer-init.js';
|
|
2
|
+
import 'preact';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Attach the sidebar drag handle to `#desktop-sidebar`. Idempotent —
|
|
6
|
+
* safe to call repeatedly (e.g. after each route swap). No-op if the
|
|
7
|
+
* sidebar element is missing or the handle is already in place.
|
|
8
|
+
*
|
|
9
|
+
* Designed to be called from the browser only. Guards against `document`
|
|
10
|
+
* being undefined so accidental SSR invocation does not throw.
|
|
11
|
+
*/
|
|
12
|
+
declare function initSidebarResizer(): void;
|
|
13
|
+
|
|
14
|
+
export { initSidebarResizer };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
const SIDEBAR_ID = "desktop-sidebar";
|
|
2
|
+
const HANDLE_MARKER = "data-sidebar-resizer";
|
|
3
|
+
const MIN_W = 192;
|
|
4
|
+
const MAX_W = 448;
|
|
5
|
+
const STEP = 10;
|
|
6
|
+
const LS_KEY = "zudo-doc-sidebar-width";
|
|
7
|
+
const CSS_PROP = "--zd-sidebar-w";
|
|
8
|
+
const ACCENT_BG = "var(--zd-accent, rgba(128,128,128,0.3))";
|
|
9
|
+
const ACCENT_OUTLINE = "2px solid var(--zd-accent, rgba(128,128,128,0.5))";
|
|
10
|
+
const ACCENT_GHOST = "var(--zd-accent, rgba(128,128,128,0.5))";
|
|
11
|
+
function initSidebarResizer() {
|
|
12
|
+
if (typeof document === "undefined") return;
|
|
13
|
+
const sidebar = document.getElementById(SIDEBAR_ID);
|
|
14
|
+
if (!sidebar || sidebar.querySelector(`[${HANDLE_MARKER}]`)) return;
|
|
15
|
+
function readCurrentWidth() {
|
|
16
|
+
const raw = getComputedStyle(document.documentElement).getPropertyValue(
|
|
17
|
+
CSS_PROP
|
|
18
|
+
);
|
|
19
|
+
return raw ? parseFloat(raw) || MIN_W : MIN_W;
|
|
20
|
+
}
|
|
21
|
+
let cachedWidth = readCurrentWidth();
|
|
22
|
+
const handle = document.createElement("div");
|
|
23
|
+
handle.setAttribute(HANDLE_MARKER, "");
|
|
24
|
+
handle.setAttribute("tabindex", "0");
|
|
25
|
+
handle.setAttribute("role", "separator");
|
|
26
|
+
handle.setAttribute("aria-orientation", "vertical");
|
|
27
|
+
handle.setAttribute("aria-label", "Resize sidebar");
|
|
28
|
+
handle.setAttribute("aria-valuemin", String(MIN_W));
|
|
29
|
+
handle.setAttribute("aria-valuemax", String(MAX_W));
|
|
30
|
+
handle.setAttribute("aria-valuenow", String(Math.round(cachedWidth)));
|
|
31
|
+
Object.assign(handle.style, {
|
|
32
|
+
position: "absolute",
|
|
33
|
+
top: "0",
|
|
34
|
+
right: "0",
|
|
35
|
+
width: "20px",
|
|
36
|
+
height: "100%",
|
|
37
|
+
cursor: "col-resize",
|
|
38
|
+
zIndex: "10",
|
|
39
|
+
transition: "background 0.15s"
|
|
40
|
+
});
|
|
41
|
+
let dragging = false;
|
|
42
|
+
let focused = false;
|
|
43
|
+
function applyWidth(w) {
|
|
44
|
+
cachedWidth = Math.max(MIN_W, Math.min(MAX_W, w));
|
|
45
|
+
document.documentElement.style.setProperty(CSS_PROP, cachedWidth + "px");
|
|
46
|
+
try {
|
|
47
|
+
localStorage.setItem(LS_KEY, String(Math.round(cachedWidth)));
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
handle.setAttribute("aria-valuenow", String(Math.round(cachedWidth)));
|
|
51
|
+
}
|
|
52
|
+
function updateHandleVisual() {
|
|
53
|
+
if (dragging || focused) {
|
|
54
|
+
handle.style.background = ACCENT_BG;
|
|
55
|
+
} else {
|
|
56
|
+
handle.style.background = "";
|
|
57
|
+
}
|
|
58
|
+
handle.style.outline = focused && !dragging ? ACCENT_OUTLINE : "";
|
|
59
|
+
handle.style.outlineOffset = focused && !dragging ? "1px" : "";
|
|
60
|
+
}
|
|
61
|
+
handle.addEventListener("focus", () => {
|
|
62
|
+
focused = true;
|
|
63
|
+
updateHandleVisual();
|
|
64
|
+
});
|
|
65
|
+
handle.addEventListener("blur", () => {
|
|
66
|
+
focused = false;
|
|
67
|
+
updateHandleVisual();
|
|
68
|
+
});
|
|
69
|
+
handle.addEventListener("keydown", (e) => {
|
|
70
|
+
let w = cachedWidth;
|
|
71
|
+
switch (e.key) {
|
|
72
|
+
case "ArrowLeft":
|
|
73
|
+
w = Math.max(MIN_W, w - STEP);
|
|
74
|
+
break;
|
|
75
|
+
case "ArrowRight":
|
|
76
|
+
w = Math.min(MAX_W, w + STEP);
|
|
77
|
+
break;
|
|
78
|
+
case "Home":
|
|
79
|
+
w = MIN_W;
|
|
80
|
+
break;
|
|
81
|
+
case "End":
|
|
82
|
+
w = MAX_W;
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
applyWidth(w);
|
|
89
|
+
});
|
|
90
|
+
handle.addEventListener("mouseenter", () => {
|
|
91
|
+
if (!dragging && !focused) handle.style.background = ACCENT_BG;
|
|
92
|
+
});
|
|
93
|
+
handle.addEventListener("mouseleave", () => {
|
|
94
|
+
if (!dragging && !focused) handle.style.background = "";
|
|
95
|
+
});
|
|
96
|
+
handle.addEventListener("pointerdown", (e) => {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
handle.setPointerCapture(e.pointerId);
|
|
99
|
+
dragging = true;
|
|
100
|
+
updateHandleVisual();
|
|
101
|
+
document.documentElement.style.cursor = "col-resize";
|
|
102
|
+
document.documentElement.style.userSelect = "none";
|
|
103
|
+
const ghost = document.createElement("div");
|
|
104
|
+
Object.assign(ghost.style, {
|
|
105
|
+
position: "fixed",
|
|
106
|
+
top: "0",
|
|
107
|
+
width: "2px",
|
|
108
|
+
height: "100vh",
|
|
109
|
+
background: ACCENT_GHOST,
|
|
110
|
+
pointerEvents: "none",
|
|
111
|
+
zIndex: "9999"
|
|
112
|
+
});
|
|
113
|
+
const sidebarRect = sidebar.getBoundingClientRect();
|
|
114
|
+
const sidebarLeft = sidebarRect.left;
|
|
115
|
+
ghost.style.left = sidebarLeft + sidebarRect.width + "px";
|
|
116
|
+
document.body.appendChild(ghost);
|
|
117
|
+
let targetWidth = 0;
|
|
118
|
+
let cleaned = false;
|
|
119
|
+
const onMove = (ev) => {
|
|
120
|
+
targetWidth = Math.max(
|
|
121
|
+
MIN_W,
|
|
122
|
+
Math.min(MAX_W, ev.clientX - sidebarLeft)
|
|
123
|
+
);
|
|
124
|
+
ghost.style.left = sidebarLeft + targetWidth + "px";
|
|
125
|
+
};
|
|
126
|
+
const cleanup = () => {
|
|
127
|
+
if (cleaned) return;
|
|
128
|
+
cleaned = true;
|
|
129
|
+
dragging = false;
|
|
130
|
+
updateHandleVisual();
|
|
131
|
+
document.documentElement.style.cursor = "";
|
|
132
|
+
document.documentElement.style.userSelect = "";
|
|
133
|
+
ghost.remove();
|
|
134
|
+
handle.removeEventListener("pointermove", onMove);
|
|
135
|
+
handle.removeEventListener("pointerup", onUp);
|
|
136
|
+
handle.removeEventListener("pointercancel", onCancel);
|
|
137
|
+
handle.removeEventListener("lostpointercapture", onLost);
|
|
138
|
+
};
|
|
139
|
+
const commit = () => {
|
|
140
|
+
if (targetWidth > 0) applyWidth(targetWidth);
|
|
141
|
+
};
|
|
142
|
+
const onUp = () => {
|
|
143
|
+
commit();
|
|
144
|
+
cleanup();
|
|
145
|
+
};
|
|
146
|
+
const onLost = () => {
|
|
147
|
+
commit();
|
|
148
|
+
cleanup();
|
|
149
|
+
};
|
|
150
|
+
const onCancel = () => {
|
|
151
|
+
cleanup();
|
|
152
|
+
};
|
|
153
|
+
handle.addEventListener("pointermove", onMove);
|
|
154
|
+
handle.addEventListener("pointerup", onUp);
|
|
155
|
+
handle.addEventListener("pointercancel", onCancel);
|
|
156
|
+
handle.addEventListener("lostpointercapture", onLost);
|
|
157
|
+
});
|
|
158
|
+
sidebar.appendChild(handle);
|
|
159
|
+
}
|
|
160
|
+
import { SidebarResizerInit, SIDEBAR_RESIZER_INIT_SCRIPT } from "./sidebar-resizer-init.js";
|
|
161
|
+
export {
|
|
162
|
+
SIDEBAR_RESIZER_INIT_SCRIPT,
|
|
163
|
+
SidebarResizerInit,
|
|
164
|
+
initSidebarResizer
|
|
165
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JSX } from 'preact';
|
|
2
|
+
|
|
3
|
+
/** @jsxImportSource preact */
|
|
4
|
+
|
|
5
|
+
declare const SIDEBAR_RESIZER_INIT_SCRIPT: string;
|
|
6
|
+
/**
|
|
7
|
+
* Drop-in JSX body-end script for sidebar resize initialization.
|
|
8
|
+
*
|
|
9
|
+
* Include once in the layout (gated on `settings.sidebarResizer`). Emits
|
|
10
|
+
* the full `initSidebarResizer` implementation as an inline
|
|
11
|
+
* `dangerouslySetInnerHTML` script so it runs without a module import.
|
|
12
|
+
*
|
|
13
|
+
* - Calls `initSidebarResizer()` once on first paint.
|
|
14
|
+
* - Re-runs on `AFTER_NAVIGATE_EVENT` (`zfb:after-swap`) for
|
|
15
|
+
* Strategy B SPA navigation support.
|
|
16
|
+
* - Idempotent: repeated calls on the same DOM are safe.
|
|
17
|
+
*/
|
|
18
|
+
declare function SidebarResizerInit(): JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { SIDEBAR_RESIZER_INIT_SCRIPT, SidebarResizerInit, SidebarResizerInit as default };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { AFTER_NAVIGATE_EVENT } from "../transitions/page-events.js";
|
|
3
|
+
const SIDEBAR_RESIZER_INIT_SCRIPT = `(function(){
|
|
4
|
+
var SIDEBAR_ID="desktop-sidebar";
|
|
5
|
+
var HANDLE_MARKER="data-sidebar-resizer";
|
|
6
|
+
var MIN_W=192,MAX_W=448,STEP=10;
|
|
7
|
+
var LS_KEY="zudo-doc-sidebar-width";
|
|
8
|
+
var CSS_PROP="--zd-sidebar-w";
|
|
9
|
+
var ACCENT_BG="var(--zd-accent,rgba(128,128,128,0.3))";
|
|
10
|
+
var ACCENT_OUTLINE="2px solid var(--zd-accent,rgba(128,128,128,0.5))";
|
|
11
|
+
var ACCENT_GHOST="var(--zd-accent,rgba(128,128,128,0.5))";
|
|
12
|
+
|
|
13
|
+
function initSidebarResizer(){
|
|
14
|
+
if(typeof document==="undefined")return;
|
|
15
|
+
var sidebar=document.getElementById(SIDEBAR_ID);
|
|
16
|
+
if(!sidebar||sidebar.querySelector("["+HANDLE_MARKER+"]"))return;
|
|
17
|
+
|
|
18
|
+
function readCurrentWidth(){
|
|
19
|
+
var raw=getComputedStyle(document.documentElement).getPropertyValue(CSS_PROP);
|
|
20
|
+
return raw?parseFloat(raw)||MIN_W:MIN_W;
|
|
21
|
+
}
|
|
22
|
+
var cachedWidth=readCurrentWidth();
|
|
23
|
+
|
|
24
|
+
var handle=document.createElement("div");
|
|
25
|
+
handle.setAttribute(HANDLE_MARKER,"");
|
|
26
|
+
handle.setAttribute("tabindex","0");
|
|
27
|
+
handle.setAttribute("role","separator");
|
|
28
|
+
handle.setAttribute("aria-orientation","vertical");
|
|
29
|
+
handle.setAttribute("aria-label","Resize sidebar");
|
|
30
|
+
handle.setAttribute("aria-valuemin",String(MIN_W));
|
|
31
|
+
handle.setAttribute("aria-valuemax",String(MAX_W));
|
|
32
|
+
handle.setAttribute("aria-valuenow",String(Math.round(cachedWidth)));
|
|
33
|
+
// 20px hit area > native y-scrollbar (~12-17px) so a draggable strip stays
|
|
34
|
+
// visible to the LEFT of the scrollbar when sidebar overflows. zudolab/zudo-doc#1660
|
|
35
|
+
Object.assign(handle.style,{position:"absolute",top:"0",right:"0",width:"20px",height:"100%",cursor:"col-resize",zIndex:"10",transition:"background 0.15s"});
|
|
36
|
+
|
|
37
|
+
var dragging=false,focused=false;
|
|
38
|
+
|
|
39
|
+
function applyWidth(w){
|
|
40
|
+
cachedWidth=Math.max(MIN_W,Math.min(MAX_W,w));
|
|
41
|
+
document.documentElement.style.setProperty(CSS_PROP,cachedWidth+"px");
|
|
42
|
+
try{localStorage.setItem(LS_KEY,String(Math.round(cachedWidth)));}catch(e){}
|
|
43
|
+
handle.setAttribute("aria-valuenow",String(Math.round(cachedWidth)));
|
|
44
|
+
}
|
|
45
|
+
function updateHandleVisual(){
|
|
46
|
+
handle.style.background=(dragging||focused)?ACCENT_BG:"";
|
|
47
|
+
handle.style.outline=(focused&&!dragging)?ACCENT_OUTLINE:"";
|
|
48
|
+
handle.style.outlineOffset=(focused&&!dragging)?"1px":"";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
handle.addEventListener("focus",function(){focused=true;updateHandleVisual();});
|
|
52
|
+
handle.addEventListener("blur",function(){focused=false;updateHandleVisual();});
|
|
53
|
+
handle.addEventListener("keydown",function(e){
|
|
54
|
+
var w=cachedWidth;
|
|
55
|
+
if(e.key==="ArrowLeft")w=Math.max(MIN_W,w-STEP);
|
|
56
|
+
else if(e.key==="ArrowRight")w=Math.min(MAX_W,w+STEP);
|
|
57
|
+
else if(e.key==="Home")w=MIN_W;
|
|
58
|
+
else if(e.key==="End")w=MAX_W;
|
|
59
|
+
else return;
|
|
60
|
+
e.preventDefault();applyWidth(w);
|
|
61
|
+
});
|
|
62
|
+
handle.addEventListener("mouseenter",function(){if(!dragging&&!focused)handle.style.background=ACCENT_BG;});
|
|
63
|
+
handle.addEventListener("mouseleave",function(){if(!dragging&&!focused)handle.style.background="";});
|
|
64
|
+
handle.addEventListener("pointerdown",function(e){
|
|
65
|
+
e.preventDefault();handle.setPointerCapture(e.pointerId);
|
|
66
|
+
dragging=true;updateHandleVisual();
|
|
67
|
+
document.documentElement.style.cursor="col-resize";
|
|
68
|
+
document.documentElement.style.userSelect="none";
|
|
69
|
+
var ghost=document.createElement("div");
|
|
70
|
+
Object.assign(ghost.style,{position:"fixed",top:"0",width:"2px",height:"100vh",background:ACCENT_GHOST,pointerEvents:"none",zIndex:"9999"});
|
|
71
|
+
var sidebarRect=sidebar.getBoundingClientRect();
|
|
72
|
+
var sidebarLeft=sidebarRect.left;
|
|
73
|
+
ghost.style.left=sidebarLeft+sidebarRect.width+"px";
|
|
74
|
+
document.body.appendChild(ghost);
|
|
75
|
+
var targetWidth=0;
|
|
76
|
+
var cleaned=false;
|
|
77
|
+
function onMove(ev){targetWidth=Math.max(MIN_W,Math.min(MAX_W,ev.clientX-sidebarLeft));ghost.style.left=sidebarLeft+targetWidth+"px";}
|
|
78
|
+
function cleanup(){
|
|
79
|
+
if(cleaned)return;cleaned=true;
|
|
80
|
+
dragging=false;updateHandleVisual();
|
|
81
|
+
document.documentElement.style.cursor="";
|
|
82
|
+
document.documentElement.style.userSelect="";
|
|
83
|
+
ghost.remove();
|
|
84
|
+
handle.removeEventListener("pointermove",onMove);
|
|
85
|
+
handle.removeEventListener("pointerup",onUp);
|
|
86
|
+
handle.removeEventListener("pointercancel",onCancel);
|
|
87
|
+
handle.removeEventListener("lostpointercapture",onLost);
|
|
88
|
+
}
|
|
89
|
+
function commit(){if(targetWidth>0)applyWidth(targetWidth);}
|
|
90
|
+
// pointerup: normal end-of-drag. Commit then teardown.
|
|
91
|
+
function onUp(){commit();cleanup();}
|
|
92
|
+
// lostpointercapture: per spec fires AFTER pointerup, but browsers reorder
|
|
93
|
+
// these in edge cases (cursor near y-scrollbar, fast drags, OS handoff).
|
|
94
|
+
// Commit here too so a real drag still applies if pointerup is dropped.
|
|
95
|
+
// Idempotent with onUp via the cleaned guard.
|
|
96
|
+
function onLost(){commit();cleanup();}
|
|
97
|
+
// pointercancel: actual user/OS cancellation (touch interrupted, etc.).
|
|
98
|
+
// Do NOT commit \u2014 caller intent was to abort.
|
|
99
|
+
function onCancel(){cleanup();}
|
|
100
|
+
handle.addEventListener("pointermove",onMove);
|
|
101
|
+
handle.addEventListener("pointerup",onUp);
|
|
102
|
+
handle.addEventListener("pointercancel",onCancel);
|
|
103
|
+
handle.addEventListener("lostpointercapture",onLost);
|
|
104
|
+
});
|
|
105
|
+
sidebar.appendChild(handle);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
initSidebarResizer();
|
|
109
|
+
document.addEventListener(${JSON.stringify(AFTER_NAVIGATE_EVENT)},initSidebarResizer);
|
|
110
|
+
})();`;
|
|
111
|
+
function SidebarResizerInit() {
|
|
112
|
+
return /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: SIDEBAR_RESIZER_INIT_SCRIPT } });
|
|
113
|
+
}
|
|
114
|
+
var sidebar_resizer_init_default = SidebarResizerInit;
|
|
115
|
+
export {
|
|
116
|
+
SIDEBAR_RESIZER_INIT_SCRIPT,
|
|
117
|
+
SidebarResizerInit,
|
|
118
|
+
sidebar_resizer_init_default as default
|
|
119
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SidebarFrontmatter, CollectionEntryLike, BuildSidebarTreeOptions, SidebarNode } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Framework-agnostic sidebar tree builder.
|
|
5
|
+
*
|
|
6
|
+
* Takes a flat list of content collection entries and emits a recursive
|
|
7
|
+
* `SidebarNode[]` that mirrors the filesystem layout — directories become
|
|
8
|
+
* category nodes, files become leaves. The shape is deliberately
|
|
9
|
+
* decoupled from astro:content so the same builder works against zfb's
|
|
10
|
+
* `getCollection` output, in-memory fixtures, etc.
|
|
11
|
+
*
|
|
12
|
+
* Ported from src/utils/docs.ts in the legacy zudo-doc Astro project.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Build a recursive sidebar tree from `entries`. Visibility filtering is
|
|
17
|
+
* applied first; the resulting structure mirrors the filesystem.
|
|
18
|
+
*
|
|
19
|
+
* - Multi-segment ids (e.g. `getting-started/intro`) walk the tree creating
|
|
20
|
+
* intermediate category nodes as needed.
|
|
21
|
+
* - Single-segment ids represent category index pages (Astro 5 strips
|
|
22
|
+
* `/index` from the id, so `getting-started/index.mdx` arrives as the id
|
|
23
|
+
* `getting-started`).
|
|
24
|
+
* - Sibling order is determined by `sidebar_position` then alphabetical
|
|
25
|
+
* slug, with the parent's `sortOrder` (from `_category_.json`) flipping
|
|
26
|
+
* the comparator when set to `"desc"`.
|
|
27
|
+
*/
|
|
28
|
+
declare function buildSidebarTree<T extends SidebarFrontmatter = SidebarFrontmatter>(entries: CollectionEntryLike<T>[], locale: string, options?: BuildSidebarTreeOptions): SidebarNode[];
|
|
29
|
+
/**
|
|
30
|
+
* Find a node by id (path slug) anywhere in the tree. Useful for sidebar
|
|
31
|
+
* config layers that resolve named doc references and for the breadcrumb
|
|
32
|
+
* builder. Exported alongside `buildSidebarTree` because both downstream
|
|
33
|
+
* topics (sub-tasks 4 and 5) need it.
|
|
34
|
+
*/
|
|
35
|
+
declare function findSidebarNode(nodes: SidebarNode[], id: string): SidebarNode | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Depth-first flatten — only nodes with a backing page are emitted, in
|
|
38
|
+
* traversal order. Mirrors the legacy `flattenTree` used for prev/next
|
|
39
|
+
* navigation.
|
|
40
|
+
*/
|
|
41
|
+
declare function flattenSidebarTree(nodes: SidebarNode[]): SidebarNode[];
|
|
42
|
+
|
|
43
|
+
export { buildSidebarTree, findSidebarNode, flattenSidebarTree };
|