@takazudo/zudo-doc 0.2.21 → 1.0.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/bin/gen-z-index.mjs +164 -0
- package/bin/tags-audit-runner.ts +126 -0
- package/bin/tags-audit.mjs +64 -0
- package/bin/zudo-doc.mjs +83 -0
- package/dist/ai-chat-modal/index.d.ts +8 -0
- package/dist/ai-chat-modal/index.js +243 -0
- package/dist/body-foot-util/body-foot-util-area.d.ts +4 -8
- package/dist/body-foot-util/edit-link.d.ts +4 -8
- package/dist/body-foot-util/index.d.ts +4 -3
- package/dist/breadcrumb/breadcrumb.d.ts +5 -9
- package/dist/breadcrumb/find-path.d.ts +2 -5
- package/dist/breadcrumb/index.d.ts +4 -4
- package/dist/breadcrumb/types.d.ts +3 -5
- package/dist/category-nav/index.d.ts +86 -0
- package/dist/category-nav/index.js +44 -0
- package/dist/category-tree-nav/index.d.ts +65 -0
- package/dist/category-tree-nav/index.js +24 -0
- package/dist/code-group/index.d.ts +10 -0
- package/dist/code-group/index.js +37 -0
- package/dist/code-syntax/code-block-enhancer-script.d.ts +1 -3
- package/dist/code-syntax/code-block-enhancer.d.ts +3 -6
- package/dist/code-syntax/index.d.ts +9 -8
- package/dist/code-syntax/mermaid-init-script.d.ts +3 -5
- package/dist/code-syntax/mermaid-init.d.ts +4 -7
- package/dist/code-syntax/tabs-init-script.d.ts +1 -3
- package/dist/code-syntax/tabs-init.d.ts +3 -6
- package/dist/code-syntax/tabs.d.ts +4 -7
- package/dist/color-scheme-utils.d.ts +125 -0
- package/dist/color-scheme-utils.js +151 -0
- package/dist/compose-meta-title/index.d.ts +7 -0
- package/dist/compose-meta-title/index.js +10 -0
- package/dist/content/component-map.d.ts +13 -17
- package/dist/content/content-blockquote.d.ts +3 -6
- package/dist/content/content-code.d.ts +3 -6
- package/dist/content/content-code.js +1 -1
- package/dist/content/content-link.d.ts +3 -6
- package/dist/content/content-link.js +1 -1
- package/dist/content/content-ol.d.ts +3 -6
- package/dist/content/content-paragraph.d.ts +3 -6
- package/dist/content/content-strong.d.ts +3 -6
- package/dist/content/content-table.d.ts +3 -6
- package/dist/content/content-ul.d.ts +3 -6
- package/dist/content/heading-h2.d.ts +3 -6
- package/dist/content/heading-h3.d.ts +3 -6
- package/dist/content/heading-h4.d.ts +3 -6
- package/dist/content/index.d.ts +29 -13
- package/dist/content-admonition/index.d.ts +15 -0
- package/dist/content-admonition/index.js +14 -0
- package/dist/design-token-panel-bootstrap.d.ts +38 -0
- package/dist/design-token-panel-bootstrap.js +29 -0
- package/dist/desktop-sidebar-toggle-island/index.d.ts +5 -0
- package/dist/desktop-sidebar-toggle-island/index.js +62 -0
- package/dist/details/details.d.ts +3 -7
- package/dist/details/index.d.ts +2 -2
- package/dist/doc-body-end/index.d.ts +21 -0
- package/dist/doc-body-end/index.js +15 -0
- package/dist/doc-content-header/index.d.ts +69 -0
- package/dist/doc-content-header/index.js +49 -0
- package/dist/doc-history/index.d.ts +10 -0
- package/dist/doc-history/index.js +407 -0
- package/dist/doc-history-area/index.d.ts +84 -0
- package/dist/doc-history-area/index.js +76 -0
- package/dist/doc-metainfo-area/index.d.ts +46 -0
- package/dist/doc-metainfo-area/index.js +41 -0
- package/dist/doc-page-props/index.d.ts +93 -0
- package/dist/doc-page-props/index.js +0 -0
- package/dist/doc-page-renderer/index.d.ts +128 -0
- package/dist/doc-page-renderer/index.js +103 -0
- package/dist/doc-page-shell/index.d.ts +136 -0
- package/dist/doc-page-shell/index.js +127 -0
- package/dist/doc-pager/index.d.ts +25 -0
- package/dist/doc-pager/index.js +41 -0
- package/dist/doc-route-entries/index.d.ts +125 -0
- package/dist/doc-route-entries/index.js +76 -0
- package/dist/doc-route-paths/index.d.ts +54 -0
- package/dist/doc-route-paths/index.js +61 -0
- package/dist/doc-tags-area/index.d.ts +38 -0
- package/dist/doc-tags-area/index.js +30 -0
- package/dist/doclayout/anchors.d.ts +7 -9
- package/dist/doclayout/doc-layout-with-defaults.d.ts +16 -12
- package/dist/doclayout/doc-layout.d.ts +5 -9
- package/dist/doclayout/index.d.ts +6 -6
- package/dist/eject/index.d.ts +33 -0
- package/dist/eject/index.js +229 -0
- package/dist/extract-headings/index.d.ts +43 -0
- package/dist/extract-headings/index.js +111 -0
- package/dist/factory-context/index.d.ts +80 -0
- package/dist/factory-context/index.js +0 -0
- package/dist/features.css +882 -0
- package/dist/footer/footer.d.ts +4 -8
- package/dist/footer/index.d.ts +13 -3
- package/dist/footer/types.d.ts +4 -6
- package/dist/footer-with-defaults/index.d.ts +63 -0
- package/dist/footer-with-defaults/index.js +128 -0
- package/dist/frontmatter-preview-data/index.d.ts +26 -0
- package/dist/frontmatter-preview-data/index.js +23 -0
- package/dist/github-helpers/index.d.ts +17 -0
- package/dist/github-helpers/index.js +16 -0
- package/dist/head/doc-head.d.ts +3 -6
- package/dist/head/index.d.ts +9 -5
- package/dist/head/og-tags.d.ts +4 -7
- package/dist/head/twitter-card.d.ts +3 -6
- package/dist/head/types.d.ts +1 -3
- package/dist/head-with-defaults/index.d.ts +49 -0
- package/dist/head-with-defaults/index.js +62 -0
- package/dist/header/header.d.ts +6 -10
- package/dist/header/index.d.ts +16 -6
- package/dist/header/nav-active.d.ts +5 -7
- package/dist/header/nav-overflow-script.d.ts +1 -3
- package/dist/header/right-items.d.ts +3 -6
- package/dist/header/types.d.ts +10 -12
- package/dist/header-with-defaults/index.d.ts +77 -0
- package/dist/header-with-defaults/index.js +163 -0
- package/dist/html-preview-wrapper/dedent.d.ts +1 -3
- package/dist/html-preview-wrapper/highlighted-code.d.ts +3 -7
- package/dist/html-preview-wrapper/html-preview-wrapper.d.ts +6 -10
- package/dist/html-preview-wrapper/html-preview.d.ts +5 -9
- package/dist/html-preview-wrapper/index.d.ts +8 -5
- package/dist/html-preview-wrapper/preflight.d.ts +1 -3
- package/dist/html-preview-wrapper/preview-base.d.ts +4 -8
- package/dist/i18n-version/index.d.ts +7 -5
- package/dist/i18n-version/language-switcher.d.ts +5 -8
- package/dist/i18n-version/types.d.ts +3 -5
- package/dist/i18n-version/version-banner.d.ts +4 -8
- package/dist/i18n-version/version-switcher.d.ts +7 -10
- package/dist/icons/index.d.ts +9 -13
- package/dist/image-enlarge/index.d.ts +13 -0
- package/dist/image-enlarge/index.js +176 -0
- package/dist/index.d.ts +26 -2
- package/dist/inline-version-switcher/index.d.ts +31 -0
- package/dist/inline-version-switcher/index.js +44 -0
- package/dist/integrations/claude-resources/escape-for-mdx.d.ts +1 -3
- package/dist/integrations/claude-resources/generate.d.ts +2 -4
- package/dist/integrations/claude-resources/index.d.ts +7 -10
- package/dist/integrations/doc-history/index.d.ts +21 -24
- package/dist/integrations/doc-history/pre-build.d.ts +7 -9
- package/dist/integrations/llms-txt/dev-middleware.d.ts +7 -11
- package/dist/integrations/llms-txt/emit.d.ts +2 -7
- package/dist/integrations/llms-txt/generate.d.ts +3 -8
- package/dist/integrations/llms-txt/index.d.ts +33 -8
- package/dist/integrations/llms-txt/load.d.ts +3 -7
- package/dist/integrations/llms-txt/strip.d.ts +2 -6
- package/dist/integrations/llms-txt/types.d.ts +9 -13
- package/dist/integrations/search-index/build-emitter.d.ts +4 -7
- package/dist/integrations/search-index/collect.d.ts +2 -5
- package/dist/integrations/search-index/dev-middleware.d.ts +5 -8
- package/dist/integrations/search-index/index.d.ts +7 -5
- package/dist/integrations/search-index/types.d.ts +5 -7
- package/dist/island-types/index.d.ts +44 -0
- package/dist/island-types/index.js +12 -0
- package/dist/locale-merge/index.d.ts +114 -0
- package/dist/locale-merge/index.js +27 -0
- package/dist/math-block/index.d.ts +18 -0
- package/dist/math-block/index.js +29 -0
- package/dist/md-utils/index.d.ts +6 -8
- package/dist/md-utils/index.js +2 -1
- package/dist/mdx-components/index.d.ts +46 -0
- package/dist/mdx-components/index.js +161 -0
- package/dist/mermaid-enlarge/index.d.ts +11 -0
- package/dist/mermaid-enlarge/index.js +290 -0
- package/dist/metainfo/doc-metainfo.d.ts +5 -9
- package/dist/metainfo/doc-tags.d.ts +7 -11
- package/dist/metainfo/frontmatter-preview.d.ts +8 -12
- package/dist/metainfo/index.d.ts +6 -4
- package/dist/nav-data-prep/index.d.ts +72 -0
- package/dist/nav-data-prep/index.js +34 -0
- package/dist/nav-indexing/category-nav.d.ts +4 -8
- package/dist/nav-indexing/category-tree-nav.d.ts +4 -8
- package/dist/nav-indexing/doc-card-grid.d.ts +4 -8
- package/dist/nav-indexing/docs-sitemap.d.ts +4 -8
- package/dist/nav-indexing/index.d.ts +37 -10
- package/dist/nav-indexing/nav-card-grid.d.ts +4 -8
- package/dist/nav-indexing/site-tree-nav-demo.d.ts +4 -8
- package/dist/nav-indexing/tag-nav.d.ts +6 -10
- package/dist/nav-indexing/types.d.ts +6 -8
- package/dist/nav-indexing/versions-page-content.d.ts +4 -8
- package/dist/nav-scope/index.d.ts +41 -0
- package/dist/nav-scope/index.js +41 -0
- package/dist/nav-source-cache/index.d.ts +13 -0
- package/dist/nav-source-cache/index.js +28 -0
- package/dist/nav-source-docs/index.d.ts +169 -0
- package/dist/nav-source-docs/index.js +123 -0
- package/dist/page-loading/index.d.ts +1 -2
- package/dist/page-loading/page-loading-overlay.d.ts +4 -8
- package/dist/plugins/claude-resources.d.ts +3 -0
- package/dist/plugins/claude-resources.js +27 -0
- package/dist/plugins/connect-adapter.d.ts +31 -0
- package/dist/plugins/connect-adapter.js +78 -0
- package/dist/plugins/doc-history.d.ts +3 -0
- package/dist/plugins/doc-history.js +54 -0
- package/dist/plugins/llms-txt.d.ts +3 -0
- package/dist/plugins/llms-txt.js +48 -0
- package/dist/plugins/plugin-utils.d.ts +17 -0
- package/dist/plugins/plugin-utils.js +11 -0
- package/dist/plugins/routes.d.ts +2 -0
- package/dist/plugins/routes.js +100 -0
- package/dist/plugins/search-index.d.ts +3 -0
- package/dist/plugins/search-index.js +24 -0
- package/dist/preset.d.ts +198 -0
- package/dist/preset.js +185 -0
- package/dist/render-markdown/index.d.ts +5 -0
- package/dist/render-markdown/index.js +115 -0
- package/dist/robots.d.ts +36 -0
- package/dist/robots.js +17 -0
- package/dist/route-enumerators/index.d.ts +204 -0
- package/dist/route-enumerators/index.js +156 -0
- package/dist/routes/404.d.ts +7 -0
- package/dist/routes/404.js +47 -0
- package/dist/routes/_chrome.d.ts +32 -0
- package/dist/routes/_chrome.js +365 -0
- package/dist/routes/_context.d.ts +56 -0
- package/dist/routes/_context.js +222 -0
- package/dist/routes/_docs-helpers.d.ts +43 -0
- package/dist/routes/_docs-helpers.js +173 -0
- package/dist/routes/_virtual.d.js +0 -0
- package/dist/routes/api-ai-chat.d.ts +5 -0
- package/dist/routes/api-ai-chat.js +24 -0
- package/dist/routes/docs-slug.d.ts +21 -0
- package/dist/routes/docs-slug.js +26 -0
- package/dist/routes/docs-tags-index.d.ts +7 -0
- package/dist/routes/docs-tags-index.js +11 -0
- package/dist/routes/docs-tags-tag.d.ts +23 -0
- package/dist/routes/docs-tags-tag.js +19 -0
- package/dist/routes/docs-versions.d.ts +7 -0
- package/dist/routes/docs-versions.js +11 -0
- package/dist/routes/index.d.ts +7 -0
- package/dist/routes/index.js +117 -0
- package/dist/routes/locale-docs-slug.d.ts +27 -0
- package/dist/routes/locale-docs-slug.js +40 -0
- package/dist/routes/locale-docs-tags-index.d.ts +18 -0
- package/dist/routes/locale-docs-tags-index.js +15 -0
- package/dist/routes/locale-docs-tags-tag.d.ts +25 -0
- package/dist/routes/locale-docs-tags-tag.js +22 -0
- package/dist/routes/locale-docs-versions.d.ts +18 -0
- package/dist/routes/locale-docs-versions.js +15 -0
- package/dist/routes/locale-index.d.ts +24 -0
- package/dist/routes/locale-index.js +132 -0
- package/dist/routes/robots.txt.d.ts +3 -0
- package/dist/routes/robots.txt.js +8 -0
- package/dist/routes/sitemap.xml.d.ts +5 -0
- package/dist/routes/sitemap.xml.js +31 -0
- package/dist/routes/v-docs-slug.d.ts +27 -0
- package/dist/routes/v-docs-slug.js +34 -0
- package/dist/routes/v-locale-docs-slug.d.ts +31 -0
- package/dist/routes/v-locale-docs-slug.js +50 -0
- package/dist/safelist.css +1 -1
- package/dist/search-widget/index.d.ts +38 -0
- package/dist/search-widget/index.js +169 -0
- package/dist/search-widget-script/index.d.ts +18 -0
- package/dist/search-widget-script/index.js +465 -0
- package/dist/settings.d.ts +270 -0
- package/dist/settings.js +0 -0
- package/dist/sidebar/index.d.ts +21 -3
- package/dist/sidebar/sidebar.d.ts +5 -9
- package/dist/sidebar/types.d.ts +4 -6
- package/dist/sidebar-prepaint/index.d.ts +21 -0
- package/dist/sidebar-prepaint/index.js +23 -0
- package/dist/sidebar-resizer/index.d.ts +2 -6
- package/dist/sidebar-resizer/sidebar-resizer-init.d.ts +6 -10
- package/dist/sidebar-toggle-island/index.d.ts +13 -0
- package/dist/sidebar-toggle-island/index.js +122 -0
- package/dist/sidebar-tree/build-tree.d.ts +4 -8
- package/dist/sidebar-tree/category-meta.d.ts +3 -6
- package/dist/sidebar-tree/index.d.ts +18 -3
- package/dist/sidebar-tree/types.d.ts +6 -8
- package/dist/sidebar-tree-island/index.d.ts +13 -0
- package/dist/sidebar-tree-island/index.js +454 -0
- package/dist/sidebar-utils/index.d.ts +64 -0
- package/dist/sidebar-utils/index.js +88 -0
- package/dist/sidebar-with-defaults/index.d.ts +38 -0
- package/dist/sidebar-with-defaults/index.js +45 -0
- package/dist/site-tree-nav/index.d.ts +71 -0
- package/dist/site-tree-nav/index.js +36 -0
- package/dist/site-tree-nav-island/index.d.ts +11 -0
- package/dist/site-tree-nav-island/index.js +176 -0
- package/dist/slug/index.d.ts +4 -0
- package/dist/slug/index.js +19 -0
- package/dist/smart-break/index.d.ts +55 -0
- package/dist/{toc/smart-break.js → smart-break/index.js} +30 -3
- package/dist/tab-item/index.d.ts +2 -2
- package/dist/tab-item/tab-item.d.ts +6 -7
- package/dist/tag-helpers/index.d.ts +40 -0
- package/dist/tag-helpers/index.js +54 -0
- package/dist/tag-pages/index.d.ts +114 -0
- package/dist/tag-pages/index.js +146 -0
- package/dist/tags-audit.d.ts +107 -0
- package/dist/tags-audit.js +321 -0
- package/dist/theme/color-scheme-provider.d.ts +4 -8
- package/dist/theme/color-tweak-export-modal.d.ts +4 -7
- package/dist/theme/design-token-serde.d.ts +14 -17
- package/dist/theme/design-token-types.d.ts +4 -6
- package/dist/theme/iframe-bridge.d.ts +12 -14
- package/dist/theme/index.d.ts +7 -9
- package/dist/theme/theme-toggle.d.ts +3 -8
- package/dist/theme-toggle/color-scheme-sync.d.ts +5 -7
- package/dist/theme-toggle/index.d.ts +4 -8
- package/dist/toc/cx.d.ts +2 -3
- package/dist/toc/index.d.ts +8 -6
- package/dist/toc/mobile-toc.d.ts +5 -9
- package/dist/toc/mobile-toc.js +1 -1
- package/dist/toc/toc-title.d.ts +1 -3
- package/dist/toc/toc.d.ts +5 -9
- package/dist/toc/toc.js +1 -1
- package/dist/toc/types.d.ts +1 -3
- package/dist/toc/use-active-heading.d.ts +4 -7
- package/dist/transitions/index.d.ts +1 -1
- package/dist/transitions/page-events.d.ts +4 -6
- package/dist/tree-nav-shared/index.d.ts +22 -0
- package/dist/tree-nav-shared/index.js +66 -0
- package/dist/url-helpers/index.d.ts +37 -0
- package/dist/url-helpers/index.js +106 -0
- package/dist/url-normalizer/index.d.ts +39 -1
- package/dist/url-normalizer/normalize.d.ts +3 -5
- package/dist/use-modal-dialog/index.d.ts +70 -0
- package/dist/use-modal-dialog/index.js +73 -0
- package/dist/versions-page/index.d.ts +55 -0
- package/dist/versions-page/index.js +73 -0
- package/eject/breadcrumb/breadcrumb.tsx +194 -0
- package/eject/breadcrumb/find-path.ts +26 -0
- package/eject/breadcrumb/index.ts +4 -0
- package/eject/breadcrumb/types.ts +32 -0
- package/eject/code-group/index.tsx +78 -0
- package/eject/content-admonition/index.tsx +50 -0
- package/eject/details/details.tsx +34 -0
- package/eject/details/index.ts +4 -0
- package/eject/doc-pager/index.tsx +91 -0
- package/eject/footer/footer.tsx +167 -0
- package/eject/footer/index.ts +19 -0
- package/eject/footer/types.ts +60 -0
- package/eject/header/header.tsx +725 -0
- package/eject/header/index.ts +36 -0
- package/eject/header/nav-active.ts +122 -0
- package/eject/header/nav-overflow-script.ts +302 -0
- package/eject/header/right-items.ts +78 -0
- package/eject/header/types.ts +69 -0
- package/eject/page-loading/index.ts +10 -0
- package/eject/page-loading/page-loading-overlay.tsx +103 -0
- package/eject/sidebar/index.ts +27 -0
- package/eject/sidebar/sidebar.tsx +137 -0
- package/eject/sidebar/types.ts +73 -0
- package/eject/tab-item/index.ts +7 -0
- package/eject/tab-item/tab-item.tsx +70 -0
- package/eject/theme-toggle/color-scheme-sync.ts +73 -0
- package/eject/theme-toggle/index.tsx +120 -0
- package/eject/toc/cx.ts +38 -0
- package/eject/toc/index.ts +11 -0
- package/eject/toc/mobile-toc.tsx +133 -0
- package/eject/toc/toc-title.ts +33 -0
- package/eject/toc/toc.tsx +119 -0
- package/eject/toc/types.ts +14 -0
- package/eject/toc/use-active-heading.ts +162 -0
- package/package.json +371 -11
- package/routes-src/404.tsx +49 -0
- package/routes-src/_chrome.tsx +470 -0
- package/routes-src/_context.ts +314 -0
- package/routes-src/_docs-helpers.ts +284 -0
- package/routes-src/_virtual.d.ts +15 -0
- package/routes-src/api-ai-chat.tsx +46 -0
- package/routes-src/docs-slug.tsx +43 -0
- package/routes-src/docs-tags-index.tsx +14 -0
- package/routes-src/docs-tags-tag.tsx +29 -0
- package/routes-src/docs-versions.tsx +15 -0
- package/routes-src/index.tsx +134 -0
- package/routes-src/locale-docs-slug.tsx +69 -0
- package/routes-src/locale-docs-tags-index.tsx +23 -0
- package/routes-src/locale-docs-tags-tag.tsx +39 -0
- package/routes-src/locale-docs-versions.tsx +23 -0
- package/routes-src/locale-index.tsx +150 -0
- package/routes-src/robots.txt.tsx +13 -0
- package/routes-src/sitemap.xml.tsx +48 -0
- package/routes-src/v-docs-slug.tsx +64 -0
- package/routes-src/v-locale-docs-slug.tsx +85 -0
- package/dist/toc/smart-break.d.ts +0 -27
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function remapVersionedHrefs(nodes, version, nodeLang, versionedDocsUrl) {
|
|
2
|
+
return nodes.map((node) => {
|
|
3
|
+
const children = node.children.length > 0 ? remapVersionedHrefs(node.children, version, nodeLang, versionedDocsUrl) : node.children;
|
|
4
|
+
if (!node.href || node.slug.startsWith("__link__")) {
|
|
5
|
+
return children !== node.children ? { ...node, children } : node;
|
|
6
|
+
}
|
|
7
|
+
const newHref = versionedDocsUrl(node.slug, version, nodeLang);
|
|
8
|
+
return { ...node, href: newHref, children };
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function buildRootMenuItems(lang, currentVersion, headerNav, t, navHref) {
|
|
12
|
+
return headerNav.map((item) => ({
|
|
13
|
+
label: item.labelKey ? t(item.labelKey, lang) : item.label,
|
|
14
|
+
href: navHref(item.path, lang, currentVersion),
|
|
15
|
+
children: item.children?.map((child) => ({
|
|
16
|
+
label: child.labelKey ? t(child.labelKey, lang) : child.label,
|
|
17
|
+
href: navHref(child.path, lang, currentVersion)
|
|
18
|
+
}))
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
function buildLocaleLinksForNav(currentPath, lang, localeCount, buildLocaleLinks) {
|
|
22
|
+
return localeCount > 1 ? buildLocaleLinks(currentPath, lang) : void 0;
|
|
23
|
+
}
|
|
24
|
+
function getThemeDefaultMode(colorMode) {
|
|
25
|
+
if (!colorMode) return void 0;
|
|
26
|
+
const mode = colorMode.defaultMode;
|
|
27
|
+
return mode === "light" || mode === "dark" ? mode : void 0;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
buildLocaleLinksForNav,
|
|
31
|
+
buildRootMenuItems,
|
|
32
|
+
getThemeDefaultMode,
|
|
33
|
+
remapVersionedHrefs
|
|
34
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { JSX } from 'preact';
|
|
2
|
-
import { NavNode } from './types.js';
|
|
3
|
-
|
|
4
1
|
/** @jsxRuntime automatic */
|
|
5
2
|
/** @jsxImportSource preact */
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { NavNode } from "./types.js";
|
|
5
|
+
export interface CategoryNavProps {
|
|
8
6
|
/**
|
|
9
7
|
* Direct children of the target category node. The consumer pre-filters to
|
|
10
8
|
* the desired category and passes the immediate children. Only nodes with
|
|
@@ -23,6 +21,4 @@ interface CategoryNavProps {
|
|
|
23
21
|
*
|
|
24
22
|
* Returns `null` when no `hasPage` children are found.
|
|
25
23
|
*/
|
|
26
|
-
declare function CategoryNav(props: CategoryNavProps): JSX.Element | null;
|
|
27
|
-
|
|
28
|
-
export { CategoryNav, type CategoryNavProps };
|
|
24
|
+
export declare function CategoryNav(props: CategoryNavProps): JSX.Element | null;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { JSX } from 'preact';
|
|
2
|
-
import { NavNode } from './types.js';
|
|
3
|
-
|
|
4
1
|
/** @jsxRuntime automatic */
|
|
5
2
|
/** @jsxImportSource preact */
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { NavNode } from "./types.js";
|
|
5
|
+
export interface CategoryTreeNavProps {
|
|
8
6
|
/**
|
|
9
7
|
* Direct children of the target category node. Nodes are filtered to
|
|
10
8
|
* those with `hasPage` or with child nodes before rendering.
|
|
@@ -22,6 +20,4 @@ interface CategoryTreeNavProps {
|
|
|
22
20
|
*
|
|
23
21
|
* Returns `null` when no renderable children exist.
|
|
24
22
|
*/
|
|
25
|
-
declare function CategoryTreeNav(props: CategoryTreeNavProps): JSX.Element | null;
|
|
26
|
-
|
|
27
|
-
export { CategoryTreeNav, type CategoryTreeNavProps };
|
|
23
|
+
export declare function CategoryTreeNav(props: CategoryTreeNavProps): JSX.Element | null;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { JSX } from 'preact';
|
|
2
|
-
|
|
3
1
|
/** @jsxRuntime automatic */
|
|
4
2
|
/** @jsxImportSource preact */
|
|
5
|
-
|
|
3
|
+
import type { JSX } from "preact";
|
|
6
4
|
/** A single resolved doc card item. */
|
|
7
|
-
interface DocCardItem {
|
|
5
|
+
export interface DocCardItem {
|
|
8
6
|
/** Pre-resolved href (base-prefixed, locale-aware). */
|
|
9
7
|
href: string;
|
|
10
8
|
/** Display title for the card. */
|
|
@@ -12,7 +10,7 @@ interface DocCardItem {
|
|
|
12
10
|
/** Optional description shown below the title. */
|
|
13
11
|
description?: string;
|
|
14
12
|
}
|
|
15
|
-
interface DocCardGridProps {
|
|
13
|
+
export interface DocCardGridProps {
|
|
16
14
|
/** Flat list of fully resolved card items. */
|
|
17
15
|
items: DocCardItem[];
|
|
18
16
|
/** Accessible label for the `<nav>` element. Defaults to "Child pages". */
|
|
@@ -33,6 +31,4 @@ interface DocCardGridProps {
|
|
|
33
31
|
*
|
|
34
32
|
* Returns `null` when `items` is empty.
|
|
35
33
|
*/
|
|
36
|
-
declare function DocCardGrid(props: DocCardGridProps): JSX.Element | null;
|
|
37
|
-
|
|
38
|
-
export { DocCardGrid, type DocCardGridProps, type DocCardItem };
|
|
34
|
+
export declare function DocCardGrid(props: DocCardGridProps): JSX.Element | null;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { JSX } from 'preact';
|
|
2
|
-
import { NavNode } from './types.js';
|
|
3
|
-
|
|
4
1
|
/** @jsxRuntime automatic */
|
|
5
2
|
/** @jsxImportSource preact */
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { NavNode } from "./types.js";
|
|
5
|
+
export interface DocsSitemapProps {
|
|
8
6
|
/**
|
|
9
7
|
* Pre-built navigation tree. Each top-level entry maps to one collapsible
|
|
10
8
|
* section in the sitemap.
|
|
@@ -20,6 +18,4 @@ interface DocsSitemapProps {
|
|
|
20
18
|
*
|
|
21
19
|
* Returns `null` when `tree` is empty.
|
|
22
20
|
*/
|
|
23
|
-
declare function DocsSitemap(props: DocsSitemapProps): JSX.Element | null;
|
|
24
|
-
|
|
25
|
-
export { DocsSitemap, type DocsSitemapProps };
|
|
21
|
+
export declare function DocsSitemap(props: DocsSitemapProps): JSX.Element | null;
|
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Public entry for the nav-indexing v2 primitives.
|
|
3
|
+
*
|
|
4
|
+
* Consumers import from `@takazudo/zudo-doc/nav-indexing`:
|
|
5
|
+
*
|
|
6
|
+
* import {
|
|
7
|
+
* CategoryNav,
|
|
8
|
+
* CategoryTreeNav,
|
|
9
|
+
* SiteTreeNavDemo,
|
|
10
|
+
* TagNav,
|
|
11
|
+
* DocsSitemap,
|
|
12
|
+
* NavCardGrid,
|
|
13
|
+
* DocCardGrid,
|
|
14
|
+
* VersionsPageContent,
|
|
15
|
+
* } from "@takazudo/zudo-doc/nav-indexing";
|
|
16
|
+
*
|
|
17
|
+
* All components are purely presentational — the host project assembles the
|
|
18
|
+
* collection data (navtrees, tag lists, version entries) before rendering.
|
|
19
|
+
* No `getCollection()` calls, no `@/` host-project imports, no Astro APIs.
|
|
20
|
+
*/
|
|
21
|
+
export { CategoryNav } from "./category-nav.js";
|
|
22
|
+
export type { CategoryNavProps } from "./category-nav.js";
|
|
23
|
+
export { CategoryTreeNav } from "./category-tree-nav.js";
|
|
24
|
+
export type { CategoryTreeNavProps } from "./category-tree-nav.js";
|
|
25
|
+
export { SiteTreeNavDemo } from "./site-tree-nav-demo.js";
|
|
26
|
+
export type { SiteTreeNavDemoProps } from "./site-tree-nav-demo.js";
|
|
27
|
+
export { TagNav } from "./tag-nav.js";
|
|
28
|
+
export type { TagNavProps, TagNavAllProps, TagNavPageProps, } from "./tag-nav.js";
|
|
29
|
+
export { DocsSitemap } from "./docs-sitemap.js";
|
|
30
|
+
export type { DocsSitemapProps } from "./docs-sitemap.js";
|
|
31
|
+
export { NavCardGrid } from "./nav-card-grid.js";
|
|
32
|
+
export type { NavCardGridProps } from "./nav-card-grid.js";
|
|
33
|
+
export { DocCardGrid } from "./doc-card-grid.js";
|
|
34
|
+
export type { DocCardGridProps, DocCardItem } from "./doc-card-grid.js";
|
|
35
|
+
export { VersionsPageContent } from "./versions-page-content.js";
|
|
36
|
+
export type { VersionsPageContentProps } from "./versions-page-content.js";
|
|
37
|
+
export type { NavNode, TagItem, TagLink, TagNavLabels, VersionPageEntry, VersionsPageLabels, } from "./types.js";
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { JSX } from 'preact';
|
|
2
|
-
import { NavNode } from './types.js';
|
|
3
|
-
|
|
4
1
|
/** @jsxRuntime automatic */
|
|
5
2
|
/** @jsxImportSource preact */
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { NavNode } from "./types.js";
|
|
5
|
+
export interface NavCardGridProps {
|
|
8
6
|
/**
|
|
9
7
|
* Direct children of the target category node. The consumer should
|
|
10
8
|
* pre-resolve `href` for each node (e.g. via `docsUrl(slug, locale)`).
|
|
@@ -26,6 +24,4 @@ interface NavCardGridProps {
|
|
|
26
24
|
*
|
|
27
25
|
* Returns `null` when no renderable items remain.
|
|
28
26
|
*/
|
|
29
|
-
declare function NavCardGrid(props: NavCardGridProps): JSX.Element | null;
|
|
30
|
-
|
|
31
|
-
export { NavCardGrid, type NavCardGridProps };
|
|
27
|
+
export declare function NavCardGrid(props: NavCardGridProps): JSX.Element | null;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { JSX } from 'preact';
|
|
2
|
-
import { NavNode } from './types.js';
|
|
3
|
-
|
|
4
1
|
/** @jsxRuntime automatic */
|
|
5
2
|
/** @jsxImportSource preact */
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { NavNode } from "./types.js";
|
|
5
|
+
export interface SiteTreeNavDemoProps {
|
|
8
6
|
/**
|
|
9
7
|
* Pre-built top-level tree nodes. The host calls buildNavTree (or
|
|
10
8
|
* buildSidebarTree) + groupSatelliteNodes before rendering this component.
|
|
@@ -34,6 +32,4 @@ interface SiteTreeNavDemoProps {
|
|
|
34
32
|
*
|
|
35
33
|
* Returns `null` when the tree is empty after filtering.
|
|
36
34
|
*/
|
|
37
|
-
declare function SiteTreeNavDemo(props: SiteTreeNavDemoProps): JSX.Element | null;
|
|
38
|
-
|
|
39
|
-
export { SiteTreeNavDemo, type SiteTreeNavDemoProps };
|
|
35
|
+
export declare function SiteTreeNavDemo(props: SiteTreeNavDemoProps): JSX.Element | null;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { JSX } from 'preact';
|
|
2
|
-
import { TagItem, TagNavLabels, TagLink } from './types.js';
|
|
3
|
-
|
|
4
1
|
/** @jsxRuntime automatic */
|
|
5
2
|
/** @jsxImportSource preact */
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { TagItem, TagLink, TagNavLabels } from "./types.js";
|
|
5
|
+
export interface TagNavAllProps {
|
|
8
6
|
variant: "all";
|
|
9
7
|
/** Pre-sorted tag list with counts and pre-resolved hrefs. */
|
|
10
8
|
tags: TagItem[];
|
|
11
9
|
/** i18n strings for aria-labels. */
|
|
12
10
|
labels: TagNavLabels;
|
|
13
11
|
}
|
|
14
|
-
interface TagNavPageProps {
|
|
12
|
+
export interface TagNavPageProps {
|
|
15
13
|
variant: "page";
|
|
16
14
|
/** Tags for the current page with pre-resolved hrefs. */
|
|
17
15
|
tagLinks: TagLink[];
|
|
18
16
|
/** i18n strings for aria-labels. */
|
|
19
17
|
labels: TagNavLabels;
|
|
20
18
|
}
|
|
21
|
-
type TagNavProps = TagNavAllProps | TagNavPageProps;
|
|
19
|
+
export type TagNavProps = TagNavAllProps | TagNavPageProps;
|
|
22
20
|
/**
|
|
23
21
|
* TagNav — JSX port of `src/components/tag-nav`.
|
|
24
22
|
*
|
|
@@ -33,6 +31,4 @@ type TagNavProps = TagNavAllProps | TagNavPageProps;
|
|
|
33
31
|
*
|
|
34
32
|
* Returns `null` when the relevant data is empty.
|
|
35
33
|
*/
|
|
36
|
-
declare function TagNav(props: TagNavProps): JSX.Element | null;
|
|
37
|
-
|
|
38
|
-
export { TagNav, type TagNavAllProps, type TagNavPageProps, type TagNavProps };
|
|
34
|
+
export declare function TagNav(props: TagNavProps): JSX.Element | null;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* `src/utils/docs.ts` and with `SidebarNode` from `sidebar-tree/`, so
|
|
13
13
|
* callers can pass either through with minor adapter mapping if needed.
|
|
14
14
|
*/
|
|
15
|
-
interface NavNode {
|
|
15
|
+
export interface NavNode {
|
|
16
16
|
label: string;
|
|
17
17
|
description?: string;
|
|
18
18
|
/** Pre-resolved href. Undefined for category-only nodes without an index page. */
|
|
@@ -24,7 +24,7 @@ interface NavNode {
|
|
|
24
24
|
/**
|
|
25
25
|
* A single tag entry with pre-resolved href — for `TagNav` "all" variant.
|
|
26
26
|
*/
|
|
27
|
-
interface TagItem {
|
|
27
|
+
export interface TagItem {
|
|
28
28
|
tag: string;
|
|
29
29
|
count: number;
|
|
30
30
|
/** Pre-resolved href including locale prefix and base path. */
|
|
@@ -33,7 +33,7 @@ interface TagItem {
|
|
|
33
33
|
/**
|
|
34
34
|
* A tag with its pre-resolved href — for `TagNav` "page" variant.
|
|
35
35
|
*/
|
|
36
|
-
interface TagLink {
|
|
36
|
+
export interface TagLink {
|
|
37
37
|
tag: string;
|
|
38
38
|
/** Pre-resolved href. */
|
|
39
39
|
href: string;
|
|
@@ -43,7 +43,7 @@ interface TagLink {
|
|
|
43
43
|
* function — the consumer resolves strings for the active locale and passes
|
|
44
44
|
* them in.
|
|
45
45
|
*/
|
|
46
|
-
interface TagNavLabels {
|
|
46
|
+
export interface TagNavLabels {
|
|
47
47
|
/** e.g. "Tags" / "タグ" — prefix label shown before the chips. */
|
|
48
48
|
tags: string;
|
|
49
49
|
/** e.g. "Pages tagged with" — used for aria-label on each chip link. */
|
|
@@ -55,7 +55,7 @@ interface TagNavLabels {
|
|
|
55
55
|
* Extends `VersionEntry` from `@takazudo/zudo-doc/i18n-version/types`
|
|
56
56
|
* with the pre-resolved doc href and optional status banner.
|
|
57
57
|
*/
|
|
58
|
-
interface VersionPageEntry {
|
|
58
|
+
export interface VersionPageEntry {
|
|
59
59
|
slug: string;
|
|
60
60
|
label: string;
|
|
61
61
|
/** Pre-resolved href to the version's default doc page. */
|
|
@@ -67,7 +67,7 @@ interface VersionPageEntry {
|
|
|
67
67
|
* i18n label bag for `VersionsPageContent`. The consumer resolves all
|
|
68
68
|
* strings for the active locale and passes them in.
|
|
69
69
|
*/
|
|
70
|
-
interface VersionsPageLabels {
|
|
70
|
+
export interface VersionsPageLabels {
|
|
71
71
|
/** Page `<h1>` text, e.g. "Documentation Versions". */
|
|
72
72
|
pageTitle: string;
|
|
73
73
|
/** Latest version section heading, e.g. "Latest Version (Current)". */
|
|
@@ -91,5 +91,3 @@ interface VersionsPageLabels {
|
|
|
91
91
|
/** Table column: docs link heading (also used as the link text). */
|
|
92
92
|
docsCol: string;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
export type { NavNode, TagItem, TagLink, TagNavLabels, VersionPageEntry, VersionsPageLabels };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { JSX } from 'preact';
|
|
2
|
-
import { VersionPageEntry, VersionsPageLabels } from './types.js';
|
|
3
|
-
|
|
4
1
|
/** @jsxRuntime automatic */
|
|
5
2
|
/** @jsxImportSource preact */
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { VersionPageEntry, VersionsPageLabels } from "./types.js";
|
|
5
|
+
export interface VersionsPageContentProps {
|
|
8
6
|
/** Pre-resolved href to the latest version's default docs page. */
|
|
9
7
|
latestHref: string;
|
|
10
8
|
/** Past version entries. Empty array hides the past-versions section. */
|
|
@@ -24,6 +22,4 @@ interface VersionsPageContentProps {
|
|
|
24
22
|
* All strings and hrefs are pre-resolved by the consumer so this component
|
|
25
23
|
* stays locale- and settings-agnostic.
|
|
26
24
|
*/
|
|
27
|
-
declare function VersionsPageContent(props: VersionsPageContentProps): JSX.Element;
|
|
28
|
-
|
|
29
|
-
export { VersionsPageContent, type VersionsPageContentProps };
|
|
25
|
+
export declare function VersionsPageContent(props: VersionsPageContentProps): JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Minimal nav node shape required by nav-scope functions. */
|
|
2
|
+
export interface NavScopeNode {
|
|
3
|
+
slug: string;
|
|
4
|
+
children: NavScopeNode[];
|
|
5
|
+
}
|
|
6
|
+
/** Minimal shape of a headerNav item the nav-scope functions need. */
|
|
7
|
+
export interface NavScopeHeaderNavItem {
|
|
8
|
+
categoryMatch?: string;
|
|
9
|
+
children?: Array<{
|
|
10
|
+
categoryMatch?: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Collect all categoryMatch strings from headerNav (including children), in order.
|
|
15
|
+
*
|
|
16
|
+
* Parameterized version of the host's `getCategoryOrder()` — receives the
|
|
17
|
+
* headerNav array instead of reading `settings.headerNav` directly.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getCategoryOrder(headerNav: NavScopeHeaderNavItem[]): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Given a doc's slug (e.g. "getting-started/introduction" or "guides/overview"),
|
|
22
|
+
* return the categoryMatch value of the headerNav item it belongs to.
|
|
23
|
+
*
|
|
24
|
+
* Parameterized version of the host's `getNavSectionForSlug()` — receives the
|
|
25
|
+
* headerNav array instead of reading `settings.headerNav` directly.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getNavSectionForSlug(slug: string, headerNav: NavScopeHeaderNavItem[]): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Filter top-level NavNodes by a headerNav categoryMatch value.
|
|
30
|
+
* - `"!"` means everything NOT claimed by explicit matchers
|
|
31
|
+
* - `"claude"` means nodes whose slug starts with `"claude"`
|
|
32
|
+
* - `undefined` means all nodes
|
|
33
|
+
*
|
|
34
|
+
* Parameterized version of the host's `getNavSubtree()` — receives the
|
|
35
|
+
* headerNav array instead of reading `settings.headerNav` directly.
|
|
36
|
+
*
|
|
37
|
+
* Generic so callers can pass their concrete node type (e.g. the host's
|
|
38
|
+
* `NavNode` which extends this shape) and get back the same type without
|
|
39
|
+
* an unsafe cast.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getNavSubtree<T extends NavScopeNode>(tree: T[], categoryMatch: string | undefined, headerNav: NavScopeHeaderNavItem[]): T[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function getCategoryOrder(headerNav) {
|
|
2
|
+
return headerNav.flatMap((item) => {
|
|
3
|
+
const matches = [];
|
|
4
|
+
if (item.categoryMatch) matches.push(item.categoryMatch);
|
|
5
|
+
if (item.children) {
|
|
6
|
+
for (const child of item.children) {
|
|
7
|
+
if (child.categoryMatch) matches.push(child.categoryMatch);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return matches;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function getNavSectionForSlug(slug, headerNav) {
|
|
14
|
+
const topCategory = slug.split("/")[0] ?? "";
|
|
15
|
+
const all = getCategoryOrder(headerNav);
|
|
16
|
+
const explicitMatches = all.filter(
|
|
17
|
+
(cm) => cm !== "!" && topCategory.startsWith(cm)
|
|
18
|
+
);
|
|
19
|
+
if (explicitMatches.length > 0) {
|
|
20
|
+
return explicitMatches.sort((a, b) => b.length - a.length)[0];
|
|
21
|
+
}
|
|
22
|
+
const defaultItem = headerNav.find(
|
|
23
|
+
(item) => item.categoryMatch === "!"
|
|
24
|
+
);
|
|
25
|
+
return defaultItem?.categoryMatch;
|
|
26
|
+
}
|
|
27
|
+
function getNavSubtree(tree, categoryMatch, headerNav) {
|
|
28
|
+
if (!categoryMatch) return tree;
|
|
29
|
+
if (categoryMatch === "!") {
|
|
30
|
+
const explicitPrefixes = getCategoryOrder(headerNav).filter((cm) => cm !== "!");
|
|
31
|
+
return tree.filter(
|
|
32
|
+
(node) => !explicitPrefixes.some((prefix) => node.slug.startsWith(prefix))
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return tree.filter((node) => node.slug.startsWith(categoryMatch));
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
getCategoryOrder,
|
|
39
|
+
getNavSectionForSlug,
|
|
40
|
+
getNavSubtree
|
|
41
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memoize a derived array (e.g. a locale merge or an `isNavVisible` filter)
|
|
3
|
+
* on the identity of its stable inputs plus a caller-supplied option
|
|
4
|
+
* signature.
|
|
5
|
+
*
|
|
6
|
+
* `inputs` MUST be the stable arrays returned by `stableDocs` (from the
|
|
7
|
+
* host's `pages/lib/_nav-source-cache.ts`) or arrays derived from them
|
|
8
|
+
* through this same helper — passing a fresh array defeats the memo.
|
|
9
|
+
* `optionSig` distinguishes call sites that differ only in filter options
|
|
10
|
+
* (e.g. `applyDefaultLocaleOnlyFilter`, `keepUnlisted`), so they never
|
|
11
|
+
* collide on the same key.
|
|
12
|
+
*/
|
|
13
|
+
export declare function memoizeDerived<T>(inputs: readonly object[], optionSig: string, compute: () => T): T;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const derivedMemo = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
const arrayId = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
let nextArrayId = 1;
|
|
4
|
+
function idOf(arr) {
|
|
5
|
+
let id = arrayId.get(arr);
|
|
6
|
+
if (id === void 0) {
|
|
7
|
+
id = nextArrayId++;
|
|
8
|
+
arrayId.set(arr, id);
|
|
9
|
+
}
|
|
10
|
+
return id;
|
|
11
|
+
}
|
|
12
|
+
const EMPTY_INPUT_ANCHOR = {};
|
|
13
|
+
function memoizeDerived(inputs, optionSig, compute) {
|
|
14
|
+
const primary = inputs[0] ?? EMPTY_INPUT_ANCHOR;
|
|
15
|
+
let sub = derivedMemo.get(primary);
|
|
16
|
+
if (!sub) {
|
|
17
|
+
sub = /* @__PURE__ */ new Map();
|
|
18
|
+
derivedMemo.set(primary, sub);
|
|
19
|
+
}
|
|
20
|
+
const key = `${inputs.map((a) => idOf(a)).join("/")}::${optionSig}`;
|
|
21
|
+
if (sub.has(key)) return sub.get(key);
|
|
22
|
+
const computed = compute();
|
|
23
|
+
sub.set(key, computed);
|
|
24
|
+
return computed;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
memoizeDerived
|
|
28
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { CategoryMeta } from "../sidebar-tree/index.js";
|
|
2
|
+
import type { DocPageEntry } from "../doc-page-props/index.js";
|
|
3
|
+
export type { CategoryMeta, DocPageEntry };
|
|
4
|
+
export interface NavSourceDocs {
|
|
5
|
+
/** Full doc list (merged + draft-filtered; unlisted retained per options). */
|
|
6
|
+
docs: DocPageEntry[];
|
|
7
|
+
/** `docs.filter(isNavVisible)` — stable instance for buildNavTree. */
|
|
8
|
+
navDocs: DocPageEntry[];
|
|
9
|
+
/** Stable category-meta Map for the active (locale, version). */
|
|
10
|
+
categoryMeta: Map<string, CategoryMeta>;
|
|
11
|
+
/** Slugs that came from the locale collection (for isFallback). Empty for
|
|
12
|
+
* default-locale / single-collection cases. */
|
|
13
|
+
localeSlugSet: ReadonlySet<string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* How to filter the merged doc list.
|
|
17
|
+
*/
|
|
18
|
+
export interface NavSourceOptions {
|
|
19
|
+
/** Drop base docs matching `defaultLocaleOnlyPrefixes` (route/sidebar nav). */
|
|
20
|
+
applyDefaultLocaleOnlyFilter?: boolean;
|
|
21
|
+
/** Retain `unlisted: true` docs (route enumeration + nav). */
|
|
22
|
+
keepUnlisted?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Optional locale config returned by `getLocaleConfig(lang)`.
|
|
26
|
+
* Structural interface so the package does not import the host's concrete type.
|
|
27
|
+
*/
|
|
28
|
+
export interface LocaleConfig {
|
|
29
|
+
/** Content directory path for this locale. */
|
|
30
|
+
dir?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Optional version config entry from `settings.versions`.
|
|
34
|
+
* Structural interface for the package.
|
|
35
|
+
*/
|
|
36
|
+
export interface VersionConfigEntry {
|
|
37
|
+
slug: string;
|
|
38
|
+
docsDir?: string;
|
|
39
|
+
locales?: Record<string, {
|
|
40
|
+
dir?: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Injected context for `createNavSourceDocs`.
|
|
45
|
+
*
|
|
46
|
+
* All host-specific singletons are passed in so the package factory never
|
|
47
|
+
* imports `@/` aliases. The host stub calls `createNavSourceDocs(ctx)` once
|
|
48
|
+
* and re-exports the returned resolver functions.
|
|
49
|
+
*/
|
|
50
|
+
export interface NavSourceDocsContext {
|
|
51
|
+
/**
|
|
52
|
+
* Default locale code (served from the un-prefixed `/docs/...` routes).
|
|
53
|
+
* E.g. `"en"`.
|
|
54
|
+
*/
|
|
55
|
+
defaultLocale: string;
|
|
56
|
+
/**
|
|
57
|
+
* The configured docs content directory (e.g. `"src/content/docs"`).
|
|
58
|
+
* Used as the base dir for `loadCategoryMeta`.
|
|
59
|
+
*/
|
|
60
|
+
docsDir: string;
|
|
61
|
+
/**
|
|
62
|
+
* Getter for the configured versions list (or false if versioning is not
|
|
63
|
+
* active). Called on every `resolveNavSource` invocation so test code that
|
|
64
|
+
* mutates `settings.versions` between calls sees the updated value.
|
|
65
|
+
* Structural equivalent of a getter for `settings.versions`.
|
|
66
|
+
*
|
|
67
|
+
* Pass `() => settings.versions` from the host stub.
|
|
68
|
+
*/
|
|
69
|
+
getVersions: () => VersionConfigEntry[] | false | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Look up locale-specific config (dir, etc.) for a locale code.
|
|
72
|
+
* Host passes `getLocaleConfig` from `@/config/i18n`.
|
|
73
|
+
*/
|
|
74
|
+
getLocaleConfig: (lang: string) => LocaleConfig | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Load category metadata for a content dir.
|
|
77
|
+
* Host passes `loadCategoryMeta` from `@/utils/docs` (re-exported from
|
|
78
|
+
* `@takazudo/zudo-doc/sidebar-tree`).
|
|
79
|
+
*/
|
|
80
|
+
loadCategoryMeta: (dir: string) => Map<string, CategoryMeta>;
|
|
81
|
+
/**
|
|
82
|
+
* Filter predicate: true when a doc should appear in navigation.
|
|
83
|
+
* Host passes `isNavVisible` from `@/utils/docs`.
|
|
84
|
+
*/
|
|
85
|
+
isNavVisible: (doc: DocPageEntry) => boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Returns true for paths that are only shown in the default locale.
|
|
88
|
+
* Host passes `isDefaultLocaleOnlyPath` from `@/utils/base`.
|
|
89
|
+
*/
|
|
90
|
+
isDefaultLocaleOnlyPath: (path: string) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Identity-stable, draft-filtered docs array for a collection.
|
|
93
|
+
* Host passes `stableDocs` from `pages/lib/_nav-source-cache.ts`.
|
|
94
|
+
* The function must anchor memoization on the zfb snapshot so the SAME
|
|
95
|
+
* array instance is returned on every call within one build.
|
|
96
|
+
*/
|
|
97
|
+
stableDocs: (collectionName: string) => DocPageEntry[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Result of `createNavSourceDocs`. Contains the resolver functions bound to
|
|
101
|
+
* the injected context.
|
|
102
|
+
*/
|
|
103
|
+
export interface NavSourceDocsAPI {
|
|
104
|
+
/**
|
|
105
|
+
* Identity-stable nav source for an EN/locale (optionally versioned) context.
|
|
106
|
+
* Every field is memoized so repeated calls with the same logical inputs
|
|
107
|
+
* return the same instances.
|
|
108
|
+
*/
|
|
109
|
+
resolveNavSource: (lang: string, currentVersion: string | undefined, options?: NavSourceOptions) => NavSourceDocs;
|
|
110
|
+
/**
|
|
111
|
+
* Identity-stable nav source for a versioned non-default-locale context —
|
|
112
|
+
* locale-specific version collection over the version's EN base.
|
|
113
|
+
*/
|
|
114
|
+
resolveVersionedLocaleSource: (versionSlug: string, versionDocsDir: string | undefined, lang: string, localeDir: string | undefined, options?: NavSourceOptions) => NavSourceDocs;
|
|
115
|
+
/**
|
|
116
|
+
* Per-page nav source for the desktop sidebar and mobile SidebarToggle.
|
|
117
|
+
*
|
|
118
|
+
* Thin adapter over `resolveNavSource` with the sidebar's filter options
|
|
119
|
+
* (`applyDefaultLocaleOnlyFilter`, `keepUnlisted`). Returns `navDocs`
|
|
120
|
+
* already filtered so callers pass it straight to `buildSidebarForSection`
|
|
121
|
+
* without a fresh `.filter(isNavVisible)` that would defeat the nav-tree
|
|
122
|
+
* fast-path.
|
|
123
|
+
*/
|
|
124
|
+
loadNavSourceDocs: (lang: string, currentVersion: string | undefined) => NavSourceDocs;
|
|
125
|
+
/**
|
|
126
|
+
* Merge category metadata for two dirs (base + locale). Result is stable per
|
|
127
|
+
* (baseDir, localeDir) pair within a build.
|
|
128
|
+
*/
|
|
129
|
+
stableMergeCategoryMeta: (baseDir: string, localeDir: string) => Map<string, CategoryMeta>;
|
|
130
|
+
/**
|
|
131
|
+
* `docs.filter(isNavVisible)`, memoized on the stable `docs` identity so the
|
|
132
|
+
* filtered array also has stable identity for the nav-tree fast-path.
|
|
133
|
+
*/
|
|
134
|
+
stableNavDocs: <T extends DocPageEntry>(docs: T[]) => T[];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create the identity-stable nav-source resolver functions bound to the host's
|
|
138
|
+
* injected context. Call this once from the host stub with the concrete
|
|
139
|
+
* singletons; re-export the returned functions.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* // pages/lib/_nav-source-docs.ts (thin stub)
|
|
144
|
+
* import { createNavSourceDocs } from "@takazudo/zudo-doc/nav-source-docs";
|
|
145
|
+
* import { settings } from "@/config/settings";
|
|
146
|
+
* import { defaultLocale, getLocaleConfig } from "@/config/i18n";
|
|
147
|
+
* import { loadCategoryMeta, isNavVisible } from "@/utils/docs";
|
|
148
|
+
* import { isDefaultLocaleOnlyPath } from "@/utils/base";
|
|
149
|
+
* import { stableDocs } from "./_nav-source-cache";
|
|
150
|
+
*
|
|
151
|
+
* export const {
|
|
152
|
+
* resolveNavSource,
|
|
153
|
+
* resolveVersionedLocaleSource,
|
|
154
|
+
* loadNavSourceDocs,
|
|
155
|
+
* stableMergeCategoryMeta,
|
|
156
|
+
* stableNavDocs,
|
|
157
|
+
* } = createNavSourceDocs({
|
|
158
|
+
* defaultLocale,
|
|
159
|
+
* docsDir: settings.docsDir,
|
|
160
|
+
* getVersions: () => settings.versions,
|
|
161
|
+
* getLocaleConfig,
|
|
162
|
+
* loadCategoryMeta,
|
|
163
|
+
* isNavVisible,
|
|
164
|
+
* isDefaultLocaleOnlyPath,
|
|
165
|
+
* stableDocs,
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare function createNavSourceDocs(ctx: NavSourceDocsContext): NavSourceDocsAPI;
|