@takazudo/zudo-doc 0.2.21 → 0.2.22
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/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/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/search-index.d.ts +3 -0
- package/dist/plugins/search-index.js +24 -0
- package/dist/preset.d.ts +152 -0
- package/dist/preset.js +169 -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/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 +255 -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/package.json +290 -10
- package/dist/toc/smart-break.d.ts +0 -27
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource preact */
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { SidebarNavNode, SidebarRootMenuItem } from "../sidebar/types.js";
|
|
5
|
+
import type { LocaleLink } from "../url-helpers/index.js";
|
|
6
|
+
export type { SidebarNavNode, SidebarRootMenuItem };
|
|
7
|
+
export interface SidebarWithDefaultsProps {
|
|
8
|
+
/** Slug of the active doc page, used to highlight the current entry. */
|
|
9
|
+
currentSlug?: string;
|
|
10
|
+
/** Active locale string, e.g. "en", "ja". */
|
|
11
|
+
lang?: string;
|
|
12
|
+
/** Header-nav category matcher used to scope the tree (e.g. "guides"). */
|
|
13
|
+
navSection?: string;
|
|
14
|
+
/** Active version slug, when rendering inside `/v/{version}/...`. */
|
|
15
|
+
currentVersion?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Current page URL path used to build the locale-switcher links shown in
|
|
18
|
+
* the mobile sidebar footer.
|
|
19
|
+
*/
|
|
20
|
+
currentPath?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Dependencies injected by the host stub. */
|
|
23
|
+
export interface SidebarWithDefaultsDeps {
|
|
24
|
+
defaultLocale: string;
|
|
25
|
+
localeCount: number;
|
|
26
|
+
buildRootMenuItems: (lang: string, currentVersion: string | undefined) => SidebarRootMenuItem[];
|
|
27
|
+
buildLocaleLinksForNav: (currentPath: string, lang: string, localeCount: number) => LocaleLink[] | undefined;
|
|
28
|
+
buildSidebarNodes: (lang: string, navSection: string | undefined, currentVersion: string | undefined, emptyWhenUnsectioned?: boolean) => SidebarNavNode[];
|
|
29
|
+
getThemeDefaultMode: () => "light" | "dark" | undefined;
|
|
30
|
+
t: (key: string, lang: string) => string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a `SidebarWithDefaults` component bound to the host's nav builders.
|
|
34
|
+
*
|
|
35
|
+
* The host stub calls this once with its concrete dependencies and re-exports
|
|
36
|
+
* the result.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createSidebarWithDefaults(deps: SidebarWithDefaultsDeps): (props: SidebarWithDefaultsProps) => JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { Island } from "@takazudo/zfb";
|
|
3
|
+
import { SidebarTree } from "../sidebar-tree-island/index.js";
|
|
4
|
+
function createSidebarWithDefaults(deps) {
|
|
5
|
+
const {
|
|
6
|
+
defaultLocale,
|
|
7
|
+
localeCount,
|
|
8
|
+
buildRootMenuItems,
|
|
9
|
+
buildLocaleLinksForNav,
|
|
10
|
+
buildSidebarNodes,
|
|
11
|
+
getThemeDefaultMode,
|
|
12
|
+
t
|
|
13
|
+
} = deps;
|
|
14
|
+
function SidebarWithDefaults(props) {
|
|
15
|
+
const {
|
|
16
|
+
currentSlug,
|
|
17
|
+
lang = defaultLocale,
|
|
18
|
+
navSection,
|
|
19
|
+
currentVersion,
|
|
20
|
+
currentPath = ""
|
|
21
|
+
} = props;
|
|
22
|
+
const rootMenuItems = buildRootMenuItems(lang, currentVersion);
|
|
23
|
+
const backToMenuLabel = navSection ? t("nav.backToMenu", lang) : void 0;
|
|
24
|
+
const nodes = buildSidebarNodes(lang, navSection, currentVersion, false);
|
|
25
|
+
const localeLinks = buildLocaleLinksForNav(currentPath, lang, localeCount);
|
|
26
|
+
return Island({
|
|
27
|
+
when: "load",
|
|
28
|
+
children: /* @__PURE__ */ jsx(
|
|
29
|
+
SidebarTree,
|
|
30
|
+
{
|
|
31
|
+
nodes,
|
|
32
|
+
currentSlug,
|
|
33
|
+
rootMenuItems,
|
|
34
|
+
backToMenuLabel,
|
|
35
|
+
localeLinks,
|
|
36
|
+
themeDefaultMode: getThemeDefaultMode()
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return SidebarWithDefaults;
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
createSidebarWithDefaults
|
|
45
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource preact */
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
import type { SidebarNavNode } from "../sidebar/types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Minimal nav source needed by the site-tree-nav factory.
|
|
7
|
+
* Typed `unknown[]` for navDocs so the factory does not import the host's
|
|
8
|
+
* concrete entry type (the host casts when injecting).
|
|
9
|
+
*/
|
|
10
|
+
export interface SiteTreeNavSource {
|
|
11
|
+
navDocs: unknown[];
|
|
12
|
+
categoryMeta: Map<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/** Props for the SiteTreeNavWrapper component. */
|
|
15
|
+
export interface SiteTreeNavWrapperProps {
|
|
16
|
+
/**
|
|
17
|
+
* Active locale. Injected via createMdxComponents() closure.
|
|
18
|
+
* Defaults to defaultLocale when not provided.
|
|
19
|
+
*/
|
|
20
|
+
lang?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional aria-label for the wrapping <nav> element.
|
|
23
|
+
* Forwarded to the v2 SiteTreeNavDemo component.
|
|
24
|
+
*/
|
|
25
|
+
ariaLabel?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Injected dependencies for {@link createSiteTreeNavWrapper}. */
|
|
28
|
+
export interface SiteTreeNavDeps {
|
|
29
|
+
/** Default locale code (e.g. `"en"`). */
|
|
30
|
+
defaultLocale: string;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the identity-stable nav source for an EN/locale context.
|
|
33
|
+
* Host passes `resolveNavSource` from `pages/lib/_nav-source-docs.ts`.
|
|
34
|
+
*/
|
|
35
|
+
resolveNavSource: (lang: string, currentVersion: string | undefined, options?: {
|
|
36
|
+
applyDefaultLocaleOnlyFilter?: boolean;
|
|
37
|
+
keepUnlisted?: boolean;
|
|
38
|
+
}) => SiteTreeNavSource;
|
|
39
|
+
/**
|
|
40
|
+
* Build the nav tree for a locale.
|
|
41
|
+
* Host passes `buildNavTree` from `@/utils/docs`.
|
|
42
|
+
* Returns `SidebarNavNode[]` — the host's NavNode is structurally
|
|
43
|
+
* compatible with SidebarNavNode (same fields including `position`).
|
|
44
|
+
*/
|
|
45
|
+
buildNavTree: (docs: unknown[], locale: string, categoryMeta: Map<string, unknown>) => SidebarNavNode[];
|
|
46
|
+
/**
|
|
47
|
+
* Group satellite nodes under target category prefixes in the nav tree.
|
|
48
|
+
* Host passes `groupSatelliteNodes` from `@/utils/docs`.
|
|
49
|
+
*/
|
|
50
|
+
groupSatelliteNodes: (tree: SidebarNavNode[], prefixes: string[]) => SidebarNavNode[];
|
|
51
|
+
/**
|
|
52
|
+
* Collect all categoryMatch strings from headerNav in order.
|
|
53
|
+
* Host passes `getCategoryOrder()` (already bound to settings.headerNav)
|
|
54
|
+
* from `@/utils/nav-scope`.
|
|
55
|
+
*/
|
|
56
|
+
getCategoryOrder: () => string[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create the `SiteTreeNavWrapper` component bound to the host's nav source
|
|
60
|
+
* and tree-building dependencies.
|
|
61
|
+
*
|
|
62
|
+
* Builds the full site nav tree and renders it via the interactive SiteTreeNav
|
|
63
|
+
* island (wrapped in Island({when:"idle"})) — restoring byte-parity with the
|
|
64
|
+
* Astro reference at /docs/components/site-tree-nav/ (refs #1453/#1442).
|
|
65
|
+
*
|
|
66
|
+
* The island renders the collapsible multi-column grid the reference shows.
|
|
67
|
+
* SiteTreeNavDemo (static <details> list) is no longer used for MDX content.
|
|
68
|
+
*
|
|
69
|
+
* Returns null when the tree is empty after filtering.
|
|
70
|
+
*/
|
|
71
|
+
export declare function createSiteTreeNavWrapper(deps: SiteTreeNavDeps): (props: SiteTreeNavWrapperProps) => JSX.Element | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { Island } from "@takazudo/zfb";
|
|
3
|
+
import { SiteTreeNav } from "../site-tree-nav-island/index.js";
|
|
4
|
+
function createSiteTreeNavWrapper(deps) {
|
|
5
|
+
const { defaultLocale, resolveNavSource, buildNavTree, groupSatelliteNodes, getCategoryOrder } = deps;
|
|
6
|
+
function SiteTreeNavWrapper({
|
|
7
|
+
lang = defaultLocale,
|
|
8
|
+
ariaLabel
|
|
9
|
+
}) {
|
|
10
|
+
const locale = lang;
|
|
11
|
+
const { navDocs, categoryMeta } = resolveNavSource(locale, void 0, {
|
|
12
|
+
applyDefaultLocaleOnlyFilter: true,
|
|
13
|
+
keepUnlisted: true
|
|
14
|
+
});
|
|
15
|
+
const tree = buildNavTree(navDocs, locale, categoryMeta);
|
|
16
|
+
const categoryOrder = getCategoryOrder();
|
|
17
|
+
const groupedTree = groupSatelliteNodes(tree, categoryOrder);
|
|
18
|
+
if (groupedTree.length === 0) return null;
|
|
19
|
+
return Island({
|
|
20
|
+
when: "idle",
|
|
21
|
+
children: /* @__PURE__ */ jsx(
|
|
22
|
+
SiteTreeNav,
|
|
23
|
+
{
|
|
24
|
+
tree: groupedTree,
|
|
25
|
+
categoryOrder,
|
|
26
|
+
categoryIgnore: ["inbox", "develop"],
|
|
27
|
+
ariaLabel
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return SiteTreeNavWrapper;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
createSiteTreeNavWrapper
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SidebarNavNode } from "../sidebar/types.js";
|
|
2
|
+
export interface SiteTreeNavProps {
|
|
3
|
+
tree: SidebarNavNode[];
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
categoryOrder?: string[];
|
|
6
|
+
categoryIgnore?: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function SiteTreeNav({ tree, ariaLabel, categoryOrder, categoryIgnore, }: SiteTreeNavProps): import("preact").JSX.Element;
|
|
9
|
+
export declare namespace SiteTreeNav {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
3
|
+
import { useState } from "preact/hooks";
|
|
4
|
+
import { INDENT, connectorLeft, ConnectorLines, CategoryLinkIcon } from "../tree-nav-shared/index.js";
|
|
5
|
+
import { ChevronRight } from "../icons/index.js";
|
|
6
|
+
const SITE_BASE_PAD = "clamp(0.5rem, 0.8vw, 1rem)";
|
|
7
|
+
function padLeft(depth) {
|
|
8
|
+
if (depth === 0) return SITE_BASE_PAD;
|
|
9
|
+
return `calc(${depth} * ${INDENT} + 1.25rem + 5px)`;
|
|
10
|
+
}
|
|
11
|
+
function reorderTree(tree, order) {
|
|
12
|
+
const map = new Map(tree.map((node) => [node.slug, node]));
|
|
13
|
+
const ordered = [];
|
|
14
|
+
for (const slug of order) {
|
|
15
|
+
const node = map.get(slug);
|
|
16
|
+
if (node) {
|
|
17
|
+
ordered.push(node);
|
|
18
|
+
map.delete(slug);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const node of map.values()) {
|
|
22
|
+
ordered.push(node);
|
|
23
|
+
}
|
|
24
|
+
return ordered;
|
|
25
|
+
}
|
|
26
|
+
function SiteTreeNav({
|
|
27
|
+
tree,
|
|
28
|
+
ariaLabel = "Site index",
|
|
29
|
+
categoryOrder,
|
|
30
|
+
categoryIgnore
|
|
31
|
+
}) {
|
|
32
|
+
let processedTree = tree;
|
|
33
|
+
if (categoryIgnore) {
|
|
34
|
+
const ignoreSet = new Set(categoryIgnore);
|
|
35
|
+
processedTree = processedTree.filter((node) => !ignoreSet.has(node.slug));
|
|
36
|
+
}
|
|
37
|
+
if (categoryOrder) {
|
|
38
|
+
processedTree = reorderTree(processedTree, categoryOrder);
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
"nav",
|
|
42
|
+
{
|
|
43
|
+
"aria-label": ariaLabel,
|
|
44
|
+
"data-site-nav": true,
|
|
45
|
+
className: "grid gap-vsp-md",
|
|
46
|
+
style: {
|
|
47
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(min(18rem, 100%), 1fr))"
|
|
48
|
+
},
|
|
49
|
+
children: processedTree.map((node) => /* @__PURE__ */ jsx("div", { className: "min-w-0 border border-muted pl-hsp-sm py-vsp-2xs", children: node.children.length > 0 ? /* @__PURE__ */ jsx(CategoryNode, { node, depth: 0, isLast: true }) : /* @__PURE__ */ jsx(LeafNode, { node, depth: 0, isLast: true }) }, node.slug))
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
SiteTreeNav.displayName = "SiteTreeNav";
|
|
54
|
+
function NodeList({ nodes, depth }) {
|
|
55
|
+
return /* @__PURE__ */ jsx(Fragment, { children: nodes.map((node, index) => {
|
|
56
|
+
const isLast = index === nodes.length - 1;
|
|
57
|
+
return node.children.length > 0 ? /* @__PURE__ */ jsx(
|
|
58
|
+
CategoryNode,
|
|
59
|
+
{
|
|
60
|
+
node,
|
|
61
|
+
depth,
|
|
62
|
+
isLast
|
|
63
|
+
},
|
|
64
|
+
node.slug
|
|
65
|
+
) : /* @__PURE__ */ jsx(
|
|
66
|
+
LeafNode,
|
|
67
|
+
{
|
|
68
|
+
node,
|
|
69
|
+
depth,
|
|
70
|
+
isLast
|
|
71
|
+
},
|
|
72
|
+
node.slug
|
|
73
|
+
);
|
|
74
|
+
}) });
|
|
75
|
+
}
|
|
76
|
+
function CategoryNode({
|
|
77
|
+
node,
|
|
78
|
+
depth,
|
|
79
|
+
isLast
|
|
80
|
+
}) {
|
|
81
|
+
const [open, setOpen] = useState(true);
|
|
82
|
+
const toggle = () => setOpen((prev) => !prev);
|
|
83
|
+
const paddingLeft = padLeft(depth);
|
|
84
|
+
return /* @__PURE__ */ jsxs("div", { className: `${depth >= 1 && !isLast ? "relative" : ""}`, children: [
|
|
85
|
+
depth >= 1 && !isLast && open && /* @__PURE__ */ jsx(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
className: "absolute border-l border-dashed border-muted z-local-1",
|
|
89
|
+
style: {
|
|
90
|
+
left: connectorLeft(depth),
|
|
91
|
+
top: 0,
|
|
92
|
+
bottom: 0
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
ConnectorLines,
|
|
99
|
+
{
|
|
100
|
+
depth,
|
|
101
|
+
isLast,
|
|
102
|
+
widthScale: 2,
|
|
103
|
+
topPad: "calc(0.15rem + var(--spacing-vsp-xs))"
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ jsxs(
|
|
107
|
+
"div",
|
|
108
|
+
{
|
|
109
|
+
className: "flex w-full items-center justify-between text-small font-semibold pt-[0.15rem] text-fg",
|
|
110
|
+
style: { paddingLeft },
|
|
111
|
+
children: [
|
|
112
|
+
node.href ? /* @__PURE__ */ jsxs(
|
|
113
|
+
"a",
|
|
114
|
+
{
|
|
115
|
+
href: node.href,
|
|
116
|
+
className: "flex-1 flex items-start gap-hsp-xs py-vsp-xs text-fg hover:text-accent hover:underline focus:underline",
|
|
117
|
+
children: [
|
|
118
|
+
depth === 0 && /* @__PURE__ */ jsx("span", { className: "flex h-[1lh] items-center", children: /* @__PURE__ */ jsx(CategoryLinkIcon, { className: "w-[18px] 2xl:w-[24px]" }) }),
|
|
119
|
+
node.label
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
) : /* @__PURE__ */ jsx(
|
|
123
|
+
"button",
|
|
124
|
+
{
|
|
125
|
+
type: "button",
|
|
126
|
+
onClick: toggle,
|
|
127
|
+
className: "flex-1 py-vsp-xs text-left hover:text-accent hover:underline focus:underline",
|
|
128
|
+
children: node.label
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
"button",
|
|
133
|
+
{
|
|
134
|
+
type: "button",
|
|
135
|
+
onClick: toggle,
|
|
136
|
+
className: "aspect-square flex items-center justify-center w-[1.75rem] border-y border-l border-muted hover:underline focus:underline",
|
|
137
|
+
"aria-expanded": open,
|
|
138
|
+
"aria-label": open ? `Collapse ${node.label}` : `Expand ${node.label}`,
|
|
139
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-icon-xs w-icon-xs transition-transform duration-150 ${open ? "rotate-90" : ""} text-muted` })
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] }),
|
|
146
|
+
open && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(NodeList, { nodes: node.children, depth: depth + 1 }) })
|
|
147
|
+
] });
|
|
148
|
+
}
|
|
149
|
+
function LeafNode({
|
|
150
|
+
node,
|
|
151
|
+
depth,
|
|
152
|
+
isLast
|
|
153
|
+
}) {
|
|
154
|
+
if (!node.href) return null;
|
|
155
|
+
const isRoot = depth === 0;
|
|
156
|
+
const paddingLeft = padLeft(depth);
|
|
157
|
+
const topPad = isRoot ? "calc(var(--spacing-vsp-xs) + 0.15rem)" : "var(--spacing-vsp-2xs)";
|
|
158
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
159
|
+
/* @__PURE__ */ jsx(ConnectorLines, { depth, isLast, widthScale: 2, topPad }),
|
|
160
|
+
/* @__PURE__ */ jsxs(
|
|
161
|
+
"a",
|
|
162
|
+
{
|
|
163
|
+
href: node.href,
|
|
164
|
+
className: isRoot ? "flex items-start gap-hsp-xs py-[calc(var(--spacing-vsp-xs)+0.15rem)] text-small font-semibold text-fg hover:text-accent hover:underline focus:underline" : `block py-vsp-2xs ${isLast ? "pb-vsp-xs" : ""} text-small text-fg hover:text-accent hover:underline focus:underline`,
|
|
165
|
+
style: { paddingLeft },
|
|
166
|
+
children: [
|
|
167
|
+
isRoot && /* @__PURE__ */ jsx("span", { className: "flex h-[1lh] items-center", children: /* @__PURE__ */ jsx(CategoryLinkIcon, { className: "w-[18px] 2xl:w-[24px]" }) }),
|
|
168
|
+
node.label
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] }) });
|
|
173
|
+
}
|
|
174
|
+
export {
|
|
175
|
+
SiteTreeNav
|
|
176
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function toRouteSlug(id) {
|
|
2
|
+
if (id === "index") return "";
|
|
3
|
+
return id.replace(/\/index$/, "");
|
|
4
|
+
}
|
|
5
|
+
function toHistorySlug(routeSlug) {
|
|
6
|
+
return routeSlug === "" ? "index" : routeSlug;
|
|
7
|
+
}
|
|
8
|
+
function toSlugParams(routeSlug) {
|
|
9
|
+
return routeSlug === "" ? [] : routeSlug.split("/");
|
|
10
|
+
}
|
|
11
|
+
function toTitleCase(str) {
|
|
12
|
+
return str.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
toHistorySlug,
|
|
16
|
+
toRouteSlug,
|
|
17
|
+
toSlugParams,
|
|
18
|
+
toTitleCase
|
|
19
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource preact */
|
|
3
|
+
import type { VNode } from "preact";
|
|
4
|
+
/**
|
|
5
|
+
* Heuristic: does `text` look like a URL, filesystem path, or similar
|
|
6
|
+
* structure where inserting <wbr> after delimiters aids line-wrapping?
|
|
7
|
+
*
|
|
8
|
+
* Returns true for URLs (contain "://"), POSIX-style absolute/relative
|
|
9
|
+
* paths ("/", "./", "../"), Windows drive paths ("C:\\..." or "C:/..."),
|
|
10
|
+
* strings with 2+ slashes (or backslashes) between alphanumerics, and
|
|
11
|
+
* plausible domain-plus-slash strings.
|
|
12
|
+
*
|
|
13
|
+
* Returns false for empty input and prose-y hyphen/slash/dot combinations
|
|
14
|
+
* like "and/or", "well-known", "state-of-the-art", "1.2.3-beta.4", "UI/UX".
|
|
15
|
+
*/
|
|
16
|
+
export declare function isPathLike(text: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* If `text` is path-like, return a Preact fragment with <wbr/> inserted
|
|
19
|
+
* after each delimiter (/, \, -, _, ., :, ?, #, &, =). Otherwise return
|
|
20
|
+
* the input string unchanged so callers can trust non-path prose passes
|
|
21
|
+
* through untouched.
|
|
22
|
+
*/
|
|
23
|
+
export declare function smartBreak(text: string): VNode | string;
|
|
24
|
+
/**
|
|
25
|
+
* Preact function component wrapper — pure, server-renderable.
|
|
26
|
+
* Stringifies children and defers to smartBreak.
|
|
27
|
+
*/
|
|
28
|
+
export declare function SmartBreak({ children }: {
|
|
29
|
+
children?: unknown;
|
|
30
|
+
}): VNode;
|
|
31
|
+
/**
|
|
32
|
+
* HTML-escape `text` and inject a literal "<wbr>" tag after every
|
|
33
|
+
* delimiter character. Unlike smartBreakToHtml, this does NOT check
|
|
34
|
+
* isPathLike — it unconditionally breaks on delimiters.
|
|
35
|
+
*
|
|
36
|
+
* Useful when a caller has already decided that a larger string is
|
|
37
|
+
* path-like and wants to apply the same wbr-injection rule to a
|
|
38
|
+
* substring (e.g. a segment produced by splitting on a search-query
|
|
39
|
+
* regex) without re-running the heuristic on fragments that are too
|
|
40
|
+
* short to be classified correctly on their own.
|
|
41
|
+
*
|
|
42
|
+
* Byte-identical to smartBreakToHtml for inputs where isPathLike is
|
|
43
|
+
* true, so the shared contract holds.
|
|
44
|
+
*/
|
|
45
|
+
export declare function escapeAndInjectWbr(text: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* HTML-string counterpart of smartBreak. Produces a safe HTML string
|
|
48
|
+
* with literal "<wbr>" tags injected after each delimiter in path-like
|
|
49
|
+
* input, and HTML-escaped text elsewhere. For non-path input, returns
|
|
50
|
+
* the HTML-escaped text unchanged (no wbr injection).
|
|
51
|
+
*
|
|
52
|
+
* Use this when the consumer cannot render Preact VNodes (e.g. building
|
|
53
|
+
* an HTML string for `set:html` / dangerouslySetInnerHTML).
|
|
54
|
+
*/
|
|
55
|
+
export declare function smartBreakToHtml(text: string): string;
|
|
@@ -14,13 +14,23 @@ function isPathLike(text) {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
const DELIM_SPLIT = /([/\\\-_.:?#&=])/;
|
|
17
|
+
const HTML_ESCAPE_MAP = {
|
|
18
|
+
"&": "&",
|
|
19
|
+
"<": "<",
|
|
20
|
+
">": ">",
|
|
21
|
+
'"': """,
|
|
22
|
+
"'": "'"
|
|
23
|
+
};
|
|
24
|
+
function htmlEscape(s) {
|
|
25
|
+
return s.replace(/[&<>"']/g, (ch) => HTML_ESCAPE_MAP[ch]);
|
|
26
|
+
}
|
|
17
27
|
function smartBreak(text) {
|
|
18
28
|
if (!isPathLike(text)) return text;
|
|
19
29
|
const parts = text.split(DELIM_SPLIT);
|
|
20
30
|
const nodes = [];
|
|
21
31
|
for (let i = 0; i < parts.length; i++) {
|
|
22
|
-
const part = parts[i];
|
|
23
|
-
if (
|
|
32
|
+
const part = parts[i] ?? "";
|
|
33
|
+
if (part === "") continue;
|
|
24
34
|
nodes.push(part);
|
|
25
35
|
if (i % 2 === 1) nodes.push(/* @__PURE__ */ jsx("wbr", {}, `wbr-${i}`));
|
|
26
36
|
}
|
|
@@ -29,8 +39,25 @@ function smartBreak(text) {
|
|
|
29
39
|
function SmartBreak({ children }) {
|
|
30
40
|
return /* @__PURE__ */ jsx(Fragment, { children: smartBreak(String(children ?? "")) });
|
|
31
41
|
}
|
|
42
|
+
function escapeAndInjectWbr(text) {
|
|
43
|
+
const parts = text.split(DELIM_SPLIT);
|
|
44
|
+
let out = "";
|
|
45
|
+
for (let i = 0; i < parts.length; i++) {
|
|
46
|
+
const part = parts[i] ?? "";
|
|
47
|
+
if (part === "") continue;
|
|
48
|
+
out += htmlEscape(part);
|
|
49
|
+
if (i % 2 === 1) out += "<wbr>";
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
function smartBreakToHtml(text) {
|
|
54
|
+
if (!isPathLike(text)) return htmlEscape(text);
|
|
55
|
+
return escapeAndInjectWbr(text);
|
|
56
|
+
}
|
|
32
57
|
export {
|
|
33
58
|
SmartBreak,
|
|
59
|
+
escapeAndInjectWbr,
|
|
34
60
|
isPathLike,
|
|
35
|
-
smartBreak
|
|
61
|
+
smartBreak,
|
|
62
|
+
smartBreakToHtml
|
|
36
63
|
};
|
package/dist/tab-item/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { TabItem,
|
|
2
|
-
|
|
1
|
+
export { TabItem, default } from "./tab-item.js";
|
|
2
|
+
export type { TabItemProps } from "./tab-item.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface TabItemProps {
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource preact */
|
|
3
|
+
import type { ComponentChildren } from "preact";
|
|
4
|
+
export interface TabItemProps {
|
|
5
5
|
/** Human-readable label rendered by the parent Tabs trigger row. */
|
|
6
6
|
label: string;
|
|
7
7
|
/**
|
|
@@ -33,6 +33,5 @@ interface TabItemProps {
|
|
|
33
33
|
* `[data-tab-default]` and reapplies `hidden` / `aria-selected` so
|
|
34
34
|
* the SSR-rendered defaults survive group sync and View Transitions.
|
|
35
35
|
*/
|
|
36
|
-
declare function TabItem({ label, value, default: isDefault, children, }: TabItemProps): preact.JSX.Element;
|
|
37
|
-
|
|
38
|
-
export { TabItem, type TabItemProps, TabItem as default };
|
|
36
|
+
export declare function TabItem({ label, value, default: isDefault, children, }: TabItemProps): import("preact").JSX.Element;
|
|
37
|
+
export default TabItem;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TagVocabularyEntry, TagGovernanceMode } from "../settings.js";
|
|
2
|
+
export type { TagVocabularyEntry, TagGovernanceMode };
|
|
3
|
+
/** Result of resolving a raw tag string. */
|
|
4
|
+
export interface ResolvedTag {
|
|
5
|
+
/** Canonical id after alias/redirect rewrites. Equal to the raw input when unchanged. */
|
|
6
|
+
canonical: string;
|
|
7
|
+
/** True when the canonical id should be dropped from aggregation (deprecated without redirect). */
|
|
8
|
+
deprecated: boolean;
|
|
9
|
+
/** True when the raw input matched a vocabulary entry (as id or alias). */
|
|
10
|
+
known: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a raw tag string to its canonical form.
|
|
14
|
+
*
|
|
15
|
+
* Parameterized version of the host's `resolveTag` — receives `tagVocabulary`
|
|
16
|
+
* and `tagGovernance` as arguments instead of reading `settings.*` at module scope.
|
|
17
|
+
*
|
|
18
|
+
* When the vocabulary is inactive (`tagVocabulary` is empty/falsy or
|
|
19
|
+
* `tagGovernance` is `"off"`), the raw value passes through unchanged with
|
|
20
|
+
* `known: false, deprecated: false`. Otherwise:
|
|
21
|
+
*
|
|
22
|
+
* - A direct id match returns that id.
|
|
23
|
+
* - An alias match returns the aliased entry's id.
|
|
24
|
+
* - `deprecated: { redirect: "<id>" }` rewrites to the redirect target.
|
|
25
|
+
* - `deprecated: true` (no redirect) returns `deprecated: true` so callers
|
|
26
|
+
* can drop the tag from aggregation.
|
|
27
|
+
* - An unknown value returns the raw string with `known: false`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveTag(raw: string, tagVocabulary: readonly TagVocabularyEntry[] | false | undefined, tagGovernance: TagGovernanceMode | undefined): ResolvedTag;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a list of raw tag strings (e.g. from frontmatter) to canonical ids,
|
|
32
|
+
* dropping deprecated-without-redirect entries and preserving order. Duplicates
|
|
33
|
+
* produced by alias collapse are removed.
|
|
34
|
+
*
|
|
35
|
+
* Builds the vocabulary index once and reuses it for all tags — O(N) index
|
|
36
|
+
* construction instead of O(N×M) when called with M tags.
|
|
37
|
+
*
|
|
38
|
+
* Parameterized version of the host's `resolvePageTags`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolvePageTags(rawTags: readonly string[], tagVocabulary: readonly TagVocabularyEntry[] | false | undefined, tagGovernance: TagGovernanceMode | undefined): string[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function buildIndex(tagVocabulary) {
|
|
2
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3
|
+
const byAlias = /* @__PURE__ */ new Map();
|
|
4
|
+
for (const entry of tagVocabulary) {
|
|
5
|
+
byId.set(entry.id, entry);
|
|
6
|
+
for (const alias of entry.aliases ?? []) byAlias.set(alias, entry);
|
|
7
|
+
}
|
|
8
|
+
return { byId, byAlias };
|
|
9
|
+
}
|
|
10
|
+
function resolveTagWithIndex(raw, index) {
|
|
11
|
+
const entry = index.byId.get(raw) ?? index.byAlias.get(raw);
|
|
12
|
+
if (!entry) return { canonical: raw, deprecated: false, known: false };
|
|
13
|
+
const dep = entry.deprecated;
|
|
14
|
+
if (dep && typeof dep === "object" && dep.redirect) {
|
|
15
|
+
const target = index.byId.get(dep.redirect);
|
|
16
|
+
if (target) return { canonical: target.id, deprecated: false, known: true };
|
|
17
|
+
return { canonical: entry.id, deprecated: true, known: true };
|
|
18
|
+
}
|
|
19
|
+
if (dep === true) {
|
|
20
|
+
return { canonical: entry.id, deprecated: true, known: true };
|
|
21
|
+
}
|
|
22
|
+
return { canonical: entry.id, deprecated: false, known: true };
|
|
23
|
+
}
|
|
24
|
+
function resolveTag(raw, tagVocabulary, tagGovernance) {
|
|
25
|
+
if (!tagVocabulary || tagGovernance === "off") {
|
|
26
|
+
return { canonical: raw, deprecated: false, known: false };
|
|
27
|
+
}
|
|
28
|
+
return resolveTagWithIndex(raw, buildIndex(tagVocabulary));
|
|
29
|
+
}
|
|
30
|
+
function resolvePageTags(rawTags, tagVocabulary, tagGovernance) {
|
|
31
|
+
const out = [];
|
|
32
|
+
const seen = /* @__PURE__ */ new Set();
|
|
33
|
+
if (!tagVocabulary || tagGovernance === "off") {
|
|
34
|
+
for (const raw of rawTags) {
|
|
35
|
+
if (seen.has(raw)) continue;
|
|
36
|
+
seen.add(raw);
|
|
37
|
+
out.push(raw);
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
const index = buildIndex(tagVocabulary);
|
|
42
|
+
for (const raw of rawTags) {
|
|
43
|
+
const { canonical, deprecated } = resolveTagWithIndex(raw, index);
|
|
44
|
+
if (deprecated) continue;
|
|
45
|
+
if (seen.has(canonical)) continue;
|
|
46
|
+
seen.add(canonical);
|
|
47
|
+
out.push(canonical);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
resolvePageTags,
|
|
53
|
+
resolveTag
|
|
54
|
+
};
|