@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,127 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { Island } from "@takazudo/zfb";
|
|
3
|
+
import { DocLayoutWithDefaults } from "../doclayout/index.js";
|
|
4
|
+
import { Toc, MobileToc } from "../toc/index.js";
|
|
5
|
+
import { Breadcrumb } from "../breadcrumb/index.js";
|
|
6
|
+
import { NavCardGrid } from "../nav-indexing/index.js";
|
|
7
|
+
function createDocPageShell(deps) {
|
|
8
|
+
const {
|
|
9
|
+
settings,
|
|
10
|
+
composeMetaTitle,
|
|
11
|
+
getTocTitle,
|
|
12
|
+
HeadWithDefaults,
|
|
13
|
+
SidebarWithDefaults,
|
|
14
|
+
HeaderWithDefaults,
|
|
15
|
+
FooterWithDefaults,
|
|
16
|
+
SidebarPrepaint,
|
|
17
|
+
DocBodyEnd,
|
|
18
|
+
DocPager
|
|
19
|
+
} = deps;
|
|
20
|
+
function DocPageShell(props) {
|
|
21
|
+
const {
|
|
22
|
+
kind,
|
|
23
|
+
locale,
|
|
24
|
+
title,
|
|
25
|
+
description,
|
|
26
|
+
canonical,
|
|
27
|
+
breadcrumbs,
|
|
28
|
+
prev,
|
|
29
|
+
next,
|
|
30
|
+
headings,
|
|
31
|
+
navSection,
|
|
32
|
+
sidebarPersistKey,
|
|
33
|
+
hideSidebar,
|
|
34
|
+
hideToc,
|
|
35
|
+
currentPath,
|
|
36
|
+
currentVersion,
|
|
37
|
+
versionSwitcher,
|
|
38
|
+
versionBanner,
|
|
39
|
+
versionBannerLatestUrl,
|
|
40
|
+
versionBannerLabels,
|
|
41
|
+
autoIndexLabel,
|
|
42
|
+
autoIndexChildren,
|
|
43
|
+
metainfoSlot,
|
|
44
|
+
contentHeaderSlot,
|
|
45
|
+
contentSlot,
|
|
46
|
+
docHistorySlot
|
|
47
|
+
} = props;
|
|
48
|
+
const tocTitle = getTocTitle(locale);
|
|
49
|
+
const shouldRenderToc = !hideToc && headings.length > 0;
|
|
50
|
+
const tocOverride = shouldRenderToc ? Island({
|
|
51
|
+
when: "load",
|
|
52
|
+
children: /* @__PURE__ */ jsx(Toc, { headings, title: tocTitle })
|
|
53
|
+
}) : void 0;
|
|
54
|
+
const mobileTocOverride = shouldRenderToc ? Island({
|
|
55
|
+
when: "load",
|
|
56
|
+
children: /* @__PURE__ */ jsx(MobileToc, { headings, title: tocTitle })
|
|
57
|
+
}) : void 0;
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
59
|
+
DocLayoutWithDefaults,
|
|
60
|
+
{
|
|
61
|
+
title: composeMetaTitle(title),
|
|
62
|
+
description: settings.metaTags.description ? description : void 0,
|
|
63
|
+
head: /* @__PURE__ */ jsx(HeadWithDefaults, { title, description, canonical }),
|
|
64
|
+
lang: locale,
|
|
65
|
+
noindex: settings.noindex,
|
|
66
|
+
hideSidebar,
|
|
67
|
+
hideToc,
|
|
68
|
+
headings,
|
|
69
|
+
canonical,
|
|
70
|
+
sidebarPersistKey,
|
|
71
|
+
versionBanner: versionBanner ?? false,
|
|
72
|
+
versionBannerLatestUrl,
|
|
73
|
+
versionBannerLabels,
|
|
74
|
+
headerOverride: /* @__PURE__ */ jsx(
|
|
75
|
+
HeaderWithDefaults,
|
|
76
|
+
{
|
|
77
|
+
lang: locale,
|
|
78
|
+
currentSlug: props.slug,
|
|
79
|
+
navSection,
|
|
80
|
+
currentVersion,
|
|
81
|
+
currentPath
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
breadcrumbOverride: breadcrumbs.length > 0 ? /* @__PURE__ */ jsx(Breadcrumb, { items: breadcrumbs, rightSlot: versionSwitcher }) : void 0,
|
|
85
|
+
sidebarOverride: /* @__PURE__ */ jsx(
|
|
86
|
+
SidebarWithDefaults,
|
|
87
|
+
{
|
|
88
|
+
currentSlug: props.slug,
|
|
89
|
+
lang: locale,
|
|
90
|
+
navSection,
|
|
91
|
+
currentVersion,
|
|
92
|
+
currentPath
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
tocOverride,
|
|
96
|
+
mobileTocOverride,
|
|
97
|
+
afterSidebar: /* @__PURE__ */ jsx(SidebarPrepaint, { hideSidebar }),
|
|
98
|
+
footerOverride: /* @__PURE__ */ jsx(FooterWithDefaults, { lang: locale }),
|
|
99
|
+
bodyEndComponents: /* @__PURE__ */ jsx(DocBodyEnd, {}),
|
|
100
|
+
enableClientRouter: settings.dynamicPageTransition,
|
|
101
|
+
children: kind === "autoIndex" ? (
|
|
102
|
+
/* Auto-index page: category without an index.mdx.
|
|
103
|
+
Fragment (not <div>) so children become direct children of
|
|
104
|
+
<article class="zd-content">, picking up the flow-space rule. */
|
|
105
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
106
|
+
/* @__PURE__ */ jsx("h1", { class: "text-heading font-bold mb-vsp-xs", children: autoIndexLabel }),
|
|
107
|
+
metainfoSlot,
|
|
108
|
+
description && /* @__PURE__ */ jsx("p", { class: "mb-vsp-lg text-title text-muted", children: description }),
|
|
109
|
+
/* @__PURE__ */ jsx(NavCardGrid, { children: autoIndexChildren ?? [] })
|
|
110
|
+
] })
|
|
111
|
+
) : (
|
|
112
|
+
/* Regular doc page. Fragment (not <div>) for the same reason. */
|
|
113
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
114
|
+
contentHeaderSlot,
|
|
115
|
+
contentSlot,
|
|
116
|
+
/* @__PURE__ */ jsx(DocPager, { prev, next, locale }),
|
|
117
|
+
docHistorySlot
|
|
118
|
+
] })
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
return DocPageShell;
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
createDocPageShell
|
|
127
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource preact */
|
|
3
|
+
import type { JSX } from "preact";
|
|
4
|
+
interface PagerNode {
|
|
5
|
+
href?: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DocPagerProps {
|
|
9
|
+
/** Previous page node (null = no previous page → renders placeholder). */
|
|
10
|
+
prev: PagerNode | null;
|
|
11
|
+
/** Next page node (null = no next page → renders placeholder). */
|
|
12
|
+
next: PagerNode | null;
|
|
13
|
+
/** Active locale for translated "Previous" / "Next" labels. */
|
|
14
|
+
locale: string;
|
|
15
|
+
}
|
|
16
|
+
/** Dependencies injected by the host stub. */
|
|
17
|
+
export interface DocPagerDeps {
|
|
18
|
+
/** Translate a UI string key for a locale. */
|
|
19
|
+
t: (key: string, locale: string) => string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a `DocPager` component bound to the host's injected `t` translator.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDocPager(deps: DocPagerDeps): (props: DocPagerProps) => JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { ChevronLeft, ChevronRight } from "../icons/index.js";
|
|
3
|
+
function createDocPager(deps) {
|
|
4
|
+
const { t } = deps;
|
|
5
|
+
function DocPager({ prev, next, locale }) {
|
|
6
|
+
return /* @__PURE__ */ jsxs("nav", { class: "mt-vsp-2xl grid grid-cols-2 gap-hsp-xl", children: [
|
|
7
|
+
prev ? /* @__PURE__ */ jsxs(
|
|
8
|
+
"a",
|
|
9
|
+
{
|
|
10
|
+
href: prev.href,
|
|
11
|
+
class: "group border border-muted rounded-lg p-hsp-lg hover:border-accent",
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ jsxs("div", { class: "flex items-center gap-hsp-xs text-caption text-muted mb-vsp-2xs", children: [
|
|
14
|
+
/* @__PURE__ */ jsx(ChevronLeft, { className: "h-[1.125rem] w-[1.125rem]" }),
|
|
15
|
+
/* @__PURE__ */ jsx("span", { class: "no-underline", children: t("nav.previous", locale) })
|
|
16
|
+
] }),
|
|
17
|
+
/* @__PURE__ */ jsx("p", { class: "text-small font-semibold underline group-hover:text-accent", children: prev.label })
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
) : /* @__PURE__ */ jsx("div", {}),
|
|
21
|
+
next ? /* @__PURE__ */ jsxs(
|
|
22
|
+
"a",
|
|
23
|
+
{
|
|
24
|
+
href: next.href,
|
|
25
|
+
class: "group border border-muted rounded-lg p-hsp-lg hover:border-accent text-right",
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsxs("div", { class: "flex items-center justify-end gap-hsp-xs text-caption text-muted mb-vsp-2xs", children: [
|
|
28
|
+
/* @__PURE__ */ jsx("span", { class: "no-underline", children: t("nav.next", locale) }),
|
|
29
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "h-[1.125rem] w-[1.125rem]" })
|
|
30
|
+
] }),
|
|
31
|
+
/* @__PURE__ */ jsx("p", { class: "text-small font-semibold underline group-hover:text-accent", children: next.label })
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
) : /* @__PURE__ */ jsx("div", {})
|
|
35
|
+
] });
|
|
36
|
+
}
|
|
37
|
+
return DocPager;
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
createDocPager
|
|
41
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { DocPageEntry, DocNavNode, AutoIndexNode, DocPageBaseProps } from "../doc-page-props/index.js";
|
|
2
|
+
import type { NavSourceDocs } from "../nav-source-docs/index.js";
|
|
3
|
+
import type { BreadcrumbItem } from "../breadcrumb/types.js";
|
|
4
|
+
import type { HeadingItem } from "../extract-headings/index.js";
|
|
5
|
+
export type { DocPageEntry, DocNavNode, AutoIndexNode, DocPageBaseProps, NavSourceDocs };
|
|
6
|
+
/** One enumerated doc route: a content entry or an auto-generated category
|
|
7
|
+
* index, with all per-page derived data pre-computed. */
|
|
8
|
+
export interface DocRouteEntry {
|
|
9
|
+
/** Canonical route slug ("" for the docs root index — #1891). */
|
|
10
|
+
slug: string;
|
|
11
|
+
/** Optional-catchall params array — `toSlugParams(slug)` ([] for the root). */
|
|
12
|
+
slugParams: string[];
|
|
13
|
+
/**
|
|
14
|
+
* True when the entry came from the base collection rather than the locale
|
|
15
|
+
* collection (`!localeSlugSet.has(slug)`). Only meaningful on routes whose
|
|
16
|
+
* nav source performs a locale merge — routes without one (default-locale /
|
|
17
|
+
* versioned-EN, where `localeSlugSet` is empty) must ignore this field.
|
|
18
|
+
* Always false for autoIndex items.
|
|
19
|
+
*/
|
|
20
|
+
isFallback: boolean;
|
|
21
|
+
/** Shared page props (kind/entry/autoIndex/breadcrumbs/prev/next/headings). */
|
|
22
|
+
props: DocPageBaseProps;
|
|
23
|
+
}
|
|
24
|
+
export interface BuildDocRouteEntriesArgs {
|
|
25
|
+
/** Identity-stable nav source for this route's (locale, version) context. */
|
|
26
|
+
source: NavSourceDocs;
|
|
27
|
+
/** Active locale for nav-tree labels and breadcrumbs. */
|
|
28
|
+
locale: string;
|
|
29
|
+
/**
|
|
30
|
+
* Unique memo signature for this route context. Each route file passes its
|
|
31
|
+
* own prefix plus the loop variables (version slug / locale), e.g.
|
|
32
|
+
* "docs;en", "locale-docs;ja", "v-docs;1.0", "v-locale-docs;1.0;ja" —
|
|
33
|
+
* call sites that share a docs array identity must never collide on a key.
|
|
34
|
+
*/
|
|
35
|
+
routeSig: string;
|
|
36
|
+
/** Versioned URL closure bound to the route's version (+ locale). Presence
|
|
37
|
+
* switches the versioned behaviors (breadcrumbs, prev/next, child hrefs). */
|
|
38
|
+
urlFor?: (slug: string) => string;
|
|
39
|
+
}
|
|
40
|
+
export type { BreadcrumbItem, HeadingItem };
|
|
41
|
+
/**
|
|
42
|
+
* Injected context for `createDocRouteEntries`.
|
|
43
|
+
*/
|
|
44
|
+
export interface DocRouteEntriesContext {
|
|
45
|
+
/**
|
|
46
|
+
* Build the nav tree for a locale from a flat entry array and category meta.
|
|
47
|
+
* Host passes `buildNavTree` from `@/utils/docs`.
|
|
48
|
+
*/
|
|
49
|
+
buildNavTree: (docs: DocPageEntry[], locale: string, categoryMeta: Map<string, unknown>) => DocNavNode[];
|
|
50
|
+
/**
|
|
51
|
+
* Build breadcrumb trail by walking the nav tree.
|
|
52
|
+
* Host passes `buildBreadcrumbs` from `@/utils/docs`.
|
|
53
|
+
*/
|
|
54
|
+
buildBreadcrumbs: (tree: DocNavNode[], slug: string, locale: string, urlFor?: (slug: string) => string) => BreadcrumbItem[];
|
|
55
|
+
/**
|
|
56
|
+
* Collect all auto-generated index nodes (categories without index.mdx).
|
|
57
|
+
* Host passes `collectAutoIndexNodes` from `@/utils/docs`.
|
|
58
|
+
*/
|
|
59
|
+
collectAutoIndexNodes: (tree: DocNavNode[]) => AutoIndexNode[];
|
|
60
|
+
/**
|
|
61
|
+
* Determine the nav section (categoryMatch) for a slug.
|
|
62
|
+
* Host passes `getNavSectionForSlug` from `@/utils/nav-scope`.
|
|
63
|
+
*/
|
|
64
|
+
getNavSectionForSlug: (slug: string) => string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Filter top-level nav nodes by a categoryMatch value.
|
|
67
|
+
* Host passes `getNavSubtree` from `@/utils/nav-scope`.
|
|
68
|
+
*/
|
|
69
|
+
getNavSubtree: (tree: DocNavNode[], categoryMatch?: string) => DocNavNode[];
|
|
70
|
+
/**
|
|
71
|
+
* Convert a content entry slug to a canonical route slug.
|
|
72
|
+
* Host passes `toRouteSlug` from `@/utils/slug` (or the package's
|
|
73
|
+
* `@takazudo/zudo-doc/slug`).
|
|
74
|
+
*/
|
|
75
|
+
toRouteSlug: (id: string) => string;
|
|
76
|
+
/**
|
|
77
|
+
* Convert a canonical route slug to an optional-catchall params array.
|
|
78
|
+
* Host passes `toSlugParams` from `@/utils/slug`.
|
|
79
|
+
*/
|
|
80
|
+
toSlugParams: (slug: string) => string[];
|
|
81
|
+
/**
|
|
82
|
+
* Extract headings from a raw MDX body.
|
|
83
|
+
* Host passes the wrapper from `pages/lib/_extract-headings.ts`.
|
|
84
|
+
*/
|
|
85
|
+
extractHeadings: (body: string) => HeadingItem[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Result of `createDocRouteEntries`. Contains the `buildDocRouteEntries`
|
|
89
|
+
* function bound to the injected context.
|
|
90
|
+
*/
|
|
91
|
+
export interface DocRouteEntriesAPI {
|
|
92
|
+
/**
|
|
93
|
+
* Enumerate all doc routes for one (locale, version) context, with per-entry
|
|
94
|
+
* derived data pre-computed. Memoized per build on the identity-stable
|
|
95
|
+
* `source.docs` array.
|
|
96
|
+
*/
|
|
97
|
+
buildDocRouteEntries: (args: BuildDocRouteEntriesArgs) => DocRouteEntry[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Create the `buildDocRouteEntries` function bound to the host's injected
|
|
101
|
+
* context.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* // pages/lib/_doc-route-entries.ts (thin stub)
|
|
106
|
+
* import { createDocRouteEntries } from "@takazudo/zudo-doc/doc-route-entries";
|
|
107
|
+
* import { buildNavTree, buildBreadcrumbs, collectAutoIndexNodes } from "@/utils/docs";
|
|
108
|
+
* import { getNavSectionForSlug, getNavSubtree } from "@/utils/nav-scope";
|
|
109
|
+
* import { toRouteSlug, toSlugParams } from "@/utils/slug";
|
|
110
|
+
* import { extractHeadings } from "./_extract-headings";
|
|
111
|
+
*
|
|
112
|
+
* export const { buildDocRouteEntries } = createDocRouteEntries({
|
|
113
|
+
* buildNavTree,
|
|
114
|
+
* buildBreadcrumbs,
|
|
115
|
+
* collectAutoIndexNodes,
|
|
116
|
+
* getNavSectionForSlug,
|
|
117
|
+
* getNavSubtree,
|
|
118
|
+
* toRouteSlug,
|
|
119
|
+
* toSlugParams,
|
|
120
|
+
* extractHeadings,
|
|
121
|
+
* });
|
|
122
|
+
* export type { DocRouteEntry, BuildDocRouteEntriesArgs };
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function createDocRouteEntries(ctx: DocRouteEntriesContext): DocRouteEntriesAPI;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { memoizeDerived } from "../nav-source-cache/index.js";
|
|
2
|
+
import {
|
|
3
|
+
resolveDocPrevNext,
|
|
4
|
+
flattenSubtree,
|
|
5
|
+
rewriteNavHref,
|
|
6
|
+
remapNavChildHrefs
|
|
7
|
+
} from "../doc-route-paths/index.js";
|
|
8
|
+
function createDocRouteEntries(ctx) {
|
|
9
|
+
const {
|
|
10
|
+
buildNavTree,
|
|
11
|
+
buildBreadcrumbs,
|
|
12
|
+
collectAutoIndexNodes,
|
|
13
|
+
getNavSectionForSlug,
|
|
14
|
+
getNavSubtree,
|
|
15
|
+
toRouteSlug,
|
|
16
|
+
toSlugParams,
|
|
17
|
+
extractHeadings
|
|
18
|
+
} = ctx;
|
|
19
|
+
function buildDocRouteEntries(args) {
|
|
20
|
+
const { source, locale, routeSig, urlFor } = args;
|
|
21
|
+
return memoizeDerived([source.docs], `docRouteEntries;${routeSig}`, () => {
|
|
22
|
+
const { docs, navDocs, categoryMeta, localeSlugSet } = source;
|
|
23
|
+
const tree = buildNavTree(navDocs, locale, categoryMeta);
|
|
24
|
+
const breadcrumbTree = urlFor ? tree : buildNavTree(docs, locale, categoryMeta);
|
|
25
|
+
const result = [];
|
|
26
|
+
for (const entry of docs) {
|
|
27
|
+
if (entry.data.category_no_page === true) continue;
|
|
28
|
+
const slug = entry.data.slug ?? toRouteSlug(entry.slug);
|
|
29
|
+
const navSection = getNavSectionForSlug(slug);
|
|
30
|
+
const subtree = getNavSubtree(tree, navSection);
|
|
31
|
+
const { prev: prevNode, next: nextNode } = resolveDocPrevNext(
|
|
32
|
+
tree,
|
|
33
|
+
flattenSubtree(subtree),
|
|
34
|
+
slug,
|
|
35
|
+
entry.data
|
|
36
|
+
);
|
|
37
|
+
result.push({
|
|
38
|
+
slug,
|
|
39
|
+
slugParams: toSlugParams(slug),
|
|
40
|
+
isFallback: !localeSlugSet.has(slug),
|
|
41
|
+
props: {
|
|
42
|
+
kind: "entry",
|
|
43
|
+
entry,
|
|
44
|
+
breadcrumbs: buildBreadcrumbs(breadcrumbTree, slug, locale, urlFor),
|
|
45
|
+
prev: rewriteNavHref(prevNode, urlFor),
|
|
46
|
+
next: rewriteNavHref(nextNode, urlFor),
|
|
47
|
+
headings: extractHeadings(entry.body ?? "")
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
for (const node of collectAutoIndexNodes(tree)) {
|
|
52
|
+
result.push({
|
|
53
|
+
slug: node.slug,
|
|
54
|
+
slugParams: toSlugParams(node.slug),
|
|
55
|
+
isFallback: false,
|
|
56
|
+
props: {
|
|
57
|
+
kind: "autoIndex",
|
|
58
|
+
autoIndex: urlFor ? {
|
|
59
|
+
...node,
|
|
60
|
+
children: remapNavChildHrefs(node.children, urlFor)
|
|
61
|
+
} : node,
|
|
62
|
+
breadcrumbs: buildBreadcrumbs(breadcrumbTree, node.slug, locale, urlFor),
|
|
63
|
+
prev: null,
|
|
64
|
+
next: null,
|
|
65
|
+
headings: []
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return { buildDocRouteEntries };
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
createDocRouteEntries
|
|
76
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DocNavNode } from "../doc-page-props/index.js";
|
|
2
|
+
export type { DocNavNode };
|
|
3
|
+
/**
|
|
4
|
+
* Flatten a nav tree into a pre-order traversal array.
|
|
5
|
+
* Mirrors `flattenTree` from `src/utils/docs.ts`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function flattenTree(nodes: DocNavNode[]): DocNavNode[];
|
|
8
|
+
/**
|
|
9
|
+
* Find a single nav node by slug in a tree.
|
|
10
|
+
* Mirrors `findNode` from `src/utils/docs.ts`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function findNode(nodes: DocNavNode[], slug: string): DocNavNode | undefined;
|
|
13
|
+
/** The two pagination-override fields read off entry frontmatter. */
|
|
14
|
+
export interface PaginationOverrides {
|
|
15
|
+
/** `undefined` = no override; `null` = suppress; string = target slug. */
|
|
16
|
+
pagination_prev?: string | null;
|
|
17
|
+
pagination_next?: string | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve prev/next nav nodes for an entry against the route's OWN nav tree.
|
|
21
|
+
*
|
|
22
|
+
* - Sequential prev/next come from the flattened sub-tree (`subtreeFlat`).
|
|
23
|
+
* - Frontmatter `pagination_prev` / `pagination_next` overrides resolve via
|
|
24
|
+
* `findNode(tree, …)` against the SAME `tree` the route built — never a
|
|
25
|
+
* foreign tree. The caller passes its own version/locale-scoped tree, so a
|
|
26
|
+
* `/v/` override resolves to a `/v/` node and a latest override to a latest
|
|
27
|
+
* node. (#1916 — pagination-override must bind to the correct tree.)
|
|
28
|
+
*
|
|
29
|
+
* Returns the raw DocNavNodes (hrefs untouched). Callers that need versioned
|
|
30
|
+
* hrefs run the result through `rewriteNavHref` with their `urlFor` closure.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveDocPrevNext(tree: DocNavNode[], subtreeFlat: DocNavNode[], slug: string, overrides: PaginationOverrides): {
|
|
33
|
+
prev: DocNavNode | null;
|
|
34
|
+
next: DocNavNode | null;
|
|
35
|
+
};
|
|
36
|
+
/** Flatten the relevant sub-tree for an entry — convenience over flattenTree. */
|
|
37
|
+
export declare function flattenSubtree(subtree: DocNavNode[]): DocNavNode[];
|
|
38
|
+
/**
|
|
39
|
+
* Rewrite a single nav node's href via the route's `urlFor` closure.
|
|
40
|
+
*
|
|
41
|
+
* Returns `null` for a `null` node. Latest routes pass `undefined` (leave the
|
|
42
|
+
* href as the latest `docsUrl` already baked into the node); versioned routes
|
|
43
|
+
* pass `urlFor` so prev/next links point at the versioned URL.
|
|
44
|
+
*/
|
|
45
|
+
export declare function rewriteNavHref(node: DocNavNode | null, urlFor: ((slug: string) => string) | undefined): DocNavNode | null;
|
|
46
|
+
/**
|
|
47
|
+
* Remap an auto-index node's child-card hrefs via `urlFor`.
|
|
48
|
+
*
|
|
49
|
+
* #1916 #2: on versioned routes the children carry latest `docsUrl` hrefs
|
|
50
|
+
* (every nav node does — see toNavNodes). They MUST be overridden to the
|
|
51
|
+
* versioned URL ALWAYS, not only when `c.href` is missing. Passing `urlFor`
|
|
52
|
+
* here does exactly that. Latest routes pass `undefined` to keep the original.
|
|
53
|
+
*/
|
|
54
|
+
export declare function remapNavChildHrefs(children: DocNavNode[], urlFor: ((slug: string) => string) | undefined): DocNavNode[];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function flattenTree(nodes) {
|
|
2
|
+
const result = [];
|
|
3
|
+
flattenInto(nodes, result);
|
|
4
|
+
return result;
|
|
5
|
+
}
|
|
6
|
+
function flattenInto(nodes, acc) {
|
|
7
|
+
for (const node of nodes) {
|
|
8
|
+
if (node.hasPage) acc.push(node);
|
|
9
|
+
flattenInto(node.children, acc);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function findNode(nodes, slug) {
|
|
13
|
+
for (const node of nodes) {
|
|
14
|
+
if (node.slug === slug) return node;
|
|
15
|
+
const found = findNode(node.children, slug);
|
|
16
|
+
if (found) return found;
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
function resolveDocPrevNext(tree, subtreeFlat, slug, overrides) {
|
|
21
|
+
const idx = subtreeFlat.findIndex((n) => n.slug === slug);
|
|
22
|
+
let prev = idx > 0 ? subtreeFlat[idx - 1] ?? null : null;
|
|
23
|
+
let next = idx >= 0 && idx < subtreeFlat.length - 1 ? subtreeFlat[idx + 1] ?? null : null;
|
|
24
|
+
if (overrides.pagination_prev !== void 0) {
|
|
25
|
+
if (overrides.pagination_prev === null) {
|
|
26
|
+
prev = null;
|
|
27
|
+
} else {
|
|
28
|
+
const found = findNode(tree, overrides.pagination_prev);
|
|
29
|
+
prev = found ?? prev;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (overrides.pagination_next !== void 0) {
|
|
33
|
+
if (overrides.pagination_next === null) {
|
|
34
|
+
next = null;
|
|
35
|
+
} else {
|
|
36
|
+
const found = findNode(tree, overrides.pagination_next);
|
|
37
|
+
next = found ?? next;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { prev, next };
|
|
41
|
+
}
|
|
42
|
+
function flattenSubtree(subtree) {
|
|
43
|
+
return flattenTree(subtree);
|
|
44
|
+
}
|
|
45
|
+
function rewriteNavHref(node, urlFor) {
|
|
46
|
+
if (!node) return null;
|
|
47
|
+
if (!urlFor) return node;
|
|
48
|
+
return { ...node, href: urlFor(node.slug) };
|
|
49
|
+
}
|
|
50
|
+
function remapNavChildHrefs(children, urlFor) {
|
|
51
|
+
if (!urlFor) return children;
|
|
52
|
+
return children.map((c) => ({ ...c, href: urlFor(c.slug) }));
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
findNode,
|
|
56
|
+
flattenSubtree,
|
|
57
|
+
flattenTree,
|
|
58
|
+
remapNavChildHrefs,
|
|
59
|
+
resolveDocPrevNext,
|
|
60
|
+
rewriteNavHref
|
|
61
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource preact */
|
|
3
|
+
import type { VNode } from "preact";
|
|
4
|
+
import type { TagVocabularyEntry, TagGovernanceMode } from "../settings.js";
|
|
5
|
+
/** Settings subset read by the DocTagsArea factory. */
|
|
6
|
+
export interface DocTagsAreaSettings {
|
|
7
|
+
docTags: boolean;
|
|
8
|
+
tagVocabulary: boolean | readonly TagVocabularyEntry[];
|
|
9
|
+
tagGovernance: TagGovernanceMode;
|
|
10
|
+
}
|
|
11
|
+
/** Dependencies injected by the host stub. */
|
|
12
|
+
export interface DocTagsAreaDeps {
|
|
13
|
+
settings: DocTagsAreaSettings;
|
|
14
|
+
/** Default locale code (e.g. "en"). */
|
|
15
|
+
defaultLocale: string;
|
|
16
|
+
/** Tag vocabulary entries (from the host's `@/config/tag-vocabulary`). */
|
|
17
|
+
tagVocabularyEntries: readonly TagVocabularyEntry[];
|
|
18
|
+
/**
|
|
19
|
+
* Build the base-prefixed tag detail page href for the given tag and locale.
|
|
20
|
+
* Host passes a pre-bound function using `withBase` and `defaultLocale`.
|
|
21
|
+
*/
|
|
22
|
+
tagHref: (tag: string, locale: string) => string;
|
|
23
|
+
/** Translate a UI string key for a locale. */
|
|
24
|
+
t: (key: string, locale: string) => string;
|
|
25
|
+
}
|
|
26
|
+
export interface DocTagsAreaProps {
|
|
27
|
+
/** Page slug, e.g. "guides/sidebar". */
|
|
28
|
+
slug: string;
|
|
29
|
+
/** Active locale string, e.g. "en", "ja". */
|
|
30
|
+
locale: string;
|
|
31
|
+
/** Raw tag strings from the page frontmatter (entry.data.tags). */
|
|
32
|
+
tags: readonly string[] | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a `DocTagsArea` component bound to the host's settings and
|
|
36
|
+
* injected dependencies.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createDocTagsArea(deps: DocTagsAreaDeps): (props: DocTagsAreaProps) => VNode | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { DocTags } from "../metainfo/index.js";
|
|
3
|
+
import { resolvePageTags } from "../tag-helpers/index.js";
|
|
4
|
+
function createDocTagsArea(deps) {
|
|
5
|
+
const { settings, tagVocabularyEntries, tagHref, t } = deps;
|
|
6
|
+
function DocTagsArea({ locale, tags }) {
|
|
7
|
+
if (!settings.docTags) return null;
|
|
8
|
+
const rawTags = tags ?? [];
|
|
9
|
+
const vocab = settings.tagVocabulary ? tagVocabularyEntries : false;
|
|
10
|
+
const canonicalTags = resolvePageTags(rawTags, vocab, settings.tagGovernance);
|
|
11
|
+
if (canonicalTags.length === 0) return null;
|
|
12
|
+
const resolvedTags = canonicalTags.map((tag) => ({
|
|
13
|
+
tag,
|
|
14
|
+
href: tagHref(tag, locale)
|
|
15
|
+
}));
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
DocTags,
|
|
18
|
+
{
|
|
19
|
+
placement: "after-title",
|
|
20
|
+
tags: resolvedTags,
|
|
21
|
+
tagsLabel: t("doc.tags", locale),
|
|
22
|
+
taggedWithLabel: t("doc.taggedWith", locale)
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return DocTagsArea;
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
createDocTagsArea
|
|
30
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the literal anchor text. This is the stable key the drift checker keys
|
|
4
4
|
* off of; the surrounding comment syntax is derived from `kind`.
|
|
5
5
|
*/
|
|
6
|
-
type DocLayoutAnchorId = "imports" | "frontmatter" | "head-scripts" | "head-links" | "header-call:start" | "header-call:end" | "after-sidebar" | "content-wrapper:start" | "content-wrapper:end" | "breadcrumb:start" | "breadcrumb:end" | "after-breadcrumb" | "after-content" | "footer" | "body-end-components" | "body-end-scripts";
|
|
6
|
+
export type DocLayoutAnchorId = "imports" | "frontmatter" | "head-scripts" | "head-links" | "header-call:start" | "header-call:end" | "after-sidebar" | "content-wrapper:start" | "content-wrapper:end" | "breadcrumb:start" | "breadcrumb:end" | "after-breadcrumb" | "after-content" | "footer" | "body-end-components" | "body-end-scripts";
|
|
7
7
|
/**
|
|
8
8
|
* Whether the anchor lives in the frontmatter region (`---` block in
|
|
9
9
|
* Astro / module-scope in JSX) or in the body markup region.
|
|
@@ -15,8 +15,8 @@ type DocLayoutAnchorId = "imports" | "frontmatter" | "head-scripts" | "head-link
|
|
|
15
15
|
* literal HTML form for byte-for-byte parity with the existing
|
|
16
16
|
* create-zudo-doc anchor strings).
|
|
17
17
|
*/
|
|
18
|
-
type DocLayoutAnchorKind = "frontmatter" | "body";
|
|
19
|
-
interface DocLayoutAnchor {
|
|
18
|
+
export type DocLayoutAnchorKind = "frontmatter" | "body";
|
|
19
|
+
export interface DocLayoutAnchor {
|
|
20
20
|
readonly id: DocLayoutAnchorId;
|
|
21
21
|
readonly kind: DocLayoutAnchorKind;
|
|
22
22
|
}
|
|
@@ -25,7 +25,7 @@ interface DocLayoutAnchor {
|
|
|
25
25
|
* doc-layout file. Order is informational (useful for the drift
|
|
26
26
|
* checker's diagnostic output); identity is what matters.
|
|
27
27
|
*/
|
|
28
|
-
declare const DOC_LAYOUT_ANCHORS: readonly DocLayoutAnchor[];
|
|
28
|
+
export declare const DOC_LAYOUT_ANCHORS: readonly DocLayoutAnchor[];
|
|
29
29
|
/**
|
|
30
30
|
* Build the literal anchor *comment string* the drift checker greps for
|
|
31
31
|
* in a scaffolded file.
|
|
@@ -39,17 +39,15 @@ declare const DOC_LAYOUT_ANCHORS: readonly DocLayoutAnchor[];
|
|
|
39
39
|
* anchorComment({ id: "footer", kind: "body" })
|
|
40
40
|
* // "<!-- @slot:doc-layout:footer -->"
|
|
41
41
|
*/
|
|
42
|
-
declare function anchorComment(anchor: DocLayoutAnchor): string;
|
|
42
|
+
export declare function anchorComment(anchor: DocLayoutAnchor): string;
|
|
43
43
|
/**
|
|
44
44
|
* Convenience: every anchor's comment string, in declaration order. The
|
|
45
45
|
* drift checker can iterate this and assert each substring appears in the
|
|
46
46
|
* scaffolded doc-layout file.
|
|
47
47
|
*/
|
|
48
|
-
declare function allAnchorComments(): readonly string[];
|
|
48
|
+
export declare function allAnchorComments(): readonly string[];
|
|
49
49
|
/**
|
|
50
50
|
* Convenience: anchor IDs as a typed set. Useful when a caller wants to
|
|
51
51
|
* verify "is this id one of ours?" without scanning the full list.
|
|
52
52
|
*/
|
|
53
|
-
declare const DOC_LAYOUT_ANCHOR_IDS: ReadonlySet<DocLayoutAnchorId>;
|
|
54
|
-
|
|
55
|
-
export { DOC_LAYOUT_ANCHORS, DOC_LAYOUT_ANCHOR_IDS, type DocLayoutAnchor, type DocLayoutAnchorId, type DocLayoutAnchorKind, allAnchorComments, anchorComment };
|
|
53
|
+
export declare const DOC_LAYOUT_ANCHOR_IDS: ReadonlySet<DocLayoutAnchorId>;
|