@takazudo/zudo-doc 0.2.20 → 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-nav.js +1 -1
- 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
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { DocLayoutProps } from './doc-layout.js';
|
|
2
|
-
import { ComponentChildren, JSX } from 'preact';
|
|
3
|
-
import { HeadingItem } from '../toc/types.js';
|
|
4
|
-
import { VersionBannerLabels } from '../i18n-version/version-banner.js';
|
|
5
|
-
export { DOC_LAYOUT_ANCHORS, DOC_LAYOUT_ANCHOR_IDS, DocLayoutAnchor, DocLayoutAnchorId, DocLayoutAnchorKind, allAnchorComments, anchorComment } from './anchors.js';
|
|
6
|
-
|
|
7
1
|
/** @jsxImportSource preact */
|
|
8
|
-
|
|
2
|
+
import type { ComponentChildren, JSX } from "preact";
|
|
3
|
+
import { type DocLayoutProps } from "./doc-layout.js";
|
|
4
|
+
import type { HeadingItem } from "../toc/types.js";
|
|
5
|
+
import { type VersionBannerLabels } from "../i18n-version/version-banner.js";
|
|
9
6
|
/**
|
|
10
7
|
* Override slots for the default-bearing wrapper. Any slot that the
|
|
11
8
|
* caller wants to replace can be passed here; otherwise the package
|
|
@@ -16,7 +13,7 @@ export { DOC_LAYOUT_ANCHORS, DOC_LAYOUT_ANCHOR_IDS, DocLayoutAnchor, DocLayoutAn
|
|
|
16
13
|
* (link columns, copyright, taglist) pass `footerOverride` with a
|
|
17
14
|
* host-side data-aware wrapper — see `pages/lib/footer-with-defaults.tsx`.
|
|
18
15
|
*/
|
|
19
|
-
interface DocLayoutWithDefaultsProps extends Omit<DocLayoutProps, "header" | "sidebar" | "toc" | "mobileToc" | "breadcrumb" | "footer" | "main"> {
|
|
16
|
+
export interface DocLayoutWithDefaultsProps extends Omit<DocLayoutProps, "header" | "sidebar" | "toc" | "mobileToc" | "breadcrumb" | "footer" | "main"> {
|
|
20
17
|
/** The page's article body. Required. */
|
|
21
18
|
children: ComponentChildren;
|
|
22
19
|
/** Replace the default site header. */
|
|
@@ -66,7 +63,16 @@ interface DocLayoutWithDefaultsProps extends Omit<DocLayoutProps, "header" | "si
|
|
|
66
63
|
/** Localized labels used by the version banner. */
|
|
67
64
|
versionBannerLabels?: VersionBannerLabels;
|
|
68
65
|
}
|
|
69
|
-
|
|
66
|
+
/**
|
|
67
|
+
* The 16 `@slot:doc-layout:*` injection-anchor strings. Wraps the
|
|
68
|
+
* canonical list from `./anchors.ts` so consumers (the drift checker,
|
|
69
|
+
* tests) can verify in one place that this wrapper carries every anchor
|
|
70
|
+
* `create-zudo-doc` knows about.
|
|
71
|
+
*
|
|
72
|
+
* The values are exposed both as the literal comment strings (what the
|
|
73
|
+
* drift checker greps for) and as the structured anchor list.
|
|
74
|
+
*/
|
|
75
|
+
export { DOC_LAYOUT_ANCHORS, DOC_LAYOUT_ANCHOR_IDS, allAnchorComments, anchorComment, type DocLayoutAnchor, type DocLayoutAnchorId, type DocLayoutAnchorKind, } from "./anchors.js";
|
|
70
76
|
/**
|
|
71
77
|
* Default-bearing wrapper. Consumers who don't need composable layout
|
|
72
78
|
* control reach for this; it forwards to `<DocLayout>` and inserts
|
|
@@ -78,6 +84,4 @@ interface DocLayoutWithDefaultsProps extends Omit<DocLayoutProps, "header" | "si
|
|
|
78
84
|
* find each anchor in both places. JSX comment expressions are
|
|
79
85
|
* compile-time-only and do not affect runtime output.
|
|
80
86
|
*/
|
|
81
|
-
declare function DocLayoutWithDefaults(props: DocLayoutWithDefaultsProps): JSX.Element;
|
|
82
|
-
|
|
83
|
-
export { DocLayoutWithDefaults, type DocLayoutWithDefaultsProps };
|
|
87
|
+
export declare function DocLayoutWithDefaults(props: DocLayoutWithDefaultsProps): JSX.Element;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { ComponentChildren, JSX } from 'preact';
|
|
2
|
-
|
|
3
1
|
/** @jsxImportSource preact */
|
|
4
|
-
|
|
2
|
+
import type { ComponentChildren, JSX } from "preact";
|
|
5
3
|
/**
|
|
6
4
|
* Direction-and-mode metadata for the root `<html>` element. Keeps the
|
|
7
5
|
* shell from depending on a project's i18n module.
|
|
8
6
|
*/
|
|
9
|
-
interface DocLayoutHtmlAttrs {
|
|
7
|
+
export interface DocLayoutHtmlAttrs {
|
|
10
8
|
/** BCP-47 language tag, e.g. `"en"`, `"ja"`. Defaults to `"en"`. */
|
|
11
9
|
lang?: string;
|
|
12
10
|
/**
|
|
@@ -26,7 +24,7 @@ interface DocLayoutHtmlAttrs {
|
|
|
26
24
|
* Island wrappers, server-rendered output projected through the
|
|
27
25
|
* boundary, etc.).
|
|
28
26
|
*/
|
|
29
|
-
interface DocLayoutProps extends DocLayoutHtmlAttrs {
|
|
27
|
+
export interface DocLayoutProps extends DocLayoutHtmlAttrs {
|
|
30
28
|
/** Page title — rendered as the `<title>` value. */
|
|
31
29
|
title: string;
|
|
32
30
|
/** Optional `<meta name="description">`. */
|
|
@@ -115,7 +113,7 @@ interface DocLayoutProps extends DocLayoutHtmlAttrs {
|
|
|
115
113
|
* `id` attribute of the desktop sidebar `<aside>`. Used by consumer code
|
|
116
114
|
* (e.g. sidebar-toggle island) to locate the element in the DOM.
|
|
117
115
|
*/
|
|
118
|
-
declare const DESKTOP_SIDEBAR_ID = "desktop-sidebar";
|
|
116
|
+
export declare const DESKTOP_SIDEBAR_ID = "desktop-sidebar";
|
|
119
117
|
/**
|
|
120
118
|
* Composable documentation-page layout shell.
|
|
121
119
|
*
|
|
@@ -124,6 +122,4 @@ declare const DESKTOP_SIDEBAR_ID = "desktop-sidebar";
|
|
|
124
122
|
* a downstream framework (e.g. `<DocLayoutWithDefaults>` or a fully
|
|
125
123
|
* custom layout) decide what fills each region.
|
|
126
124
|
*/
|
|
127
|
-
declare function DocLayout(props: DocLayoutProps): JSX.Element;
|
|
128
|
-
|
|
129
|
-
export { DESKTOP_SIDEBAR_ID, DocLayout, type DocLayoutHtmlAttrs, type DocLayoutProps };
|
|
125
|
+
export declare function DocLayout(props: DocLayoutProps): JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export { DocLayout, DESKTOP_SIDEBAR_ID } from "./doc-layout.js";
|
|
2
|
+
export type { DocLayoutProps, DocLayoutHtmlAttrs, } from "./doc-layout.js";
|
|
3
|
+
export { DocLayoutWithDefaults } from "./doc-layout-with-defaults.js";
|
|
4
|
+
export type { DocLayoutWithDefaultsProps } from "./doc-layout-with-defaults.js";
|
|
5
|
+
export { DOC_LAYOUT_ANCHORS, DOC_LAYOUT_ANCHOR_IDS, allAnchorComments, anchorComment, } from "./anchors.js";
|
|
6
|
+
export type { DocLayoutAnchor, DocLayoutAnchorId, DocLayoutAnchorKind, } from "./anchors.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Heading-ID (anchor) strategy. Mirrors `settings.headingIdStrategy`. */
|
|
2
|
+
export type HeadingIdStrategy = "flat" | "hierarchical";
|
|
3
|
+
/**
|
|
4
|
+
* Slugify one heading's text — a byte-faithful TS port of zfb's Rust `slugify`
|
|
5
|
+
* (`crates/zfb-content/src/plugins/heading_links.rs`). Using the exact upstream
|
|
6
|
+
* algorithm (rather than npm `github-slugger`, which strips punctuation
|
|
7
|
+
* differently) is what keeps the TOC anchor identical to the rendered `id`.
|
|
8
|
+
*
|
|
9
|
+
* Rule: walk code points; whitespace, ASCII control, or a {@link SLUGIFY_STRIPPED}
|
|
10
|
+
* char collapses to a single `-` (runs coalesce); every other char is lowercased
|
|
11
|
+
* and kept (Unicode letters/digits, `-`, `_` survive). A single trailing `-` is
|
|
12
|
+
* dropped; a leading `-` is never emitted.
|
|
13
|
+
*/
|
|
14
|
+
export declare function slugify(input: string): string;
|
|
15
|
+
export interface HeadingItem {
|
|
16
|
+
readonly depth: number;
|
|
17
|
+
readonly slug: string;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Extract TOC headings from a raw MDX/markdown body.
|
|
22
|
+
*
|
|
23
|
+
* Uses the same slugging algorithm as zfb's `HeadingLinks` plugin (selected by
|
|
24
|
+
* `opts.strategy`) so the `href="#slug"` values in the TOC match the rendered
|
|
25
|
+
* heading element IDs. Allocates over ALL matched h2–h6 (keeping the dedup
|
|
26
|
+
* counter and hierarchical ancestor stack in sync with the renderer) but only
|
|
27
|
+
* pushes depth 2–4 items into the result (configurable via opts). h1 is not
|
|
28
|
+
* matched — the renderer does not assign ids to h1.
|
|
29
|
+
*
|
|
30
|
+
* Unlike the original showcase version, this function takes all settings as
|
|
31
|
+
* explicit parameters rather than reading from the project's `settings` singleton.
|
|
32
|
+
* This keeps the package import-graph free of project singletons.
|
|
33
|
+
*
|
|
34
|
+
* @param body - Raw markdown body string (frontmatter already stripped).
|
|
35
|
+
* @param opts - Settings for heading depth window and ID strategy. Production
|
|
36
|
+
* call sites should pass values from the project's `settings` object.
|
|
37
|
+
* @returns Array of `{ depth, slug, text }` items in document order.
|
|
38
|
+
*/
|
|
39
|
+
export declare function extractHeadings(body: string, opts?: {
|
|
40
|
+
tocMinDepth?: number;
|
|
41
|
+
tocMaxDepth?: number;
|
|
42
|
+
strategy?: HeadingIdStrategy;
|
|
43
|
+
}): HeadingItem[];
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const SLUGIFY_STRIPPED = new Set(
|
|
2
|
+
"!\"#$%&'()*+,./:;<=>?@[\\]^`{|}~".split("")
|
|
3
|
+
);
|
|
4
|
+
function slugify(input) {
|
|
5
|
+
let out = "";
|
|
6
|
+
let lastDash = true;
|
|
7
|
+
for (const ch of input) {
|
|
8
|
+
const cp = ch.codePointAt(0) ?? 0;
|
|
9
|
+
const isControl = cp <= 31 || cp >= 127 && cp <= 159;
|
|
10
|
+
if (isControl || /\s/u.test(ch) || SLUGIFY_STRIPPED.has(ch)) {
|
|
11
|
+
if (!lastDash) {
|
|
12
|
+
out += "-";
|
|
13
|
+
lastDash = true;
|
|
14
|
+
}
|
|
15
|
+
} else {
|
|
16
|
+
out += ch.toLowerCase();
|
|
17
|
+
lastDash = false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (out.endsWith("-")) out = out.slice(0, -1);
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
class SlugAllocator {
|
|
24
|
+
strategy;
|
|
25
|
+
/** Dedup counter, keyed by the (possibly ancestor-prefixed) slug path. */
|
|
26
|
+
seen = /* @__PURE__ */ new Map();
|
|
27
|
+
/** Hierarchical ancestor stack of `{ depth, final id }` (unused when flat). */
|
|
28
|
+
stack = [];
|
|
29
|
+
constructor(strategy) {
|
|
30
|
+
this.strategy = strategy;
|
|
31
|
+
}
|
|
32
|
+
allocate(depth, text) {
|
|
33
|
+
const base = slugify(text);
|
|
34
|
+
if (this.strategy === "flat") {
|
|
35
|
+
return this.nextSlug(base);
|
|
36
|
+
}
|
|
37
|
+
if (base === "") return "";
|
|
38
|
+
for (let top = this.stack.at(-1); top !== void 0 && top.depth >= depth; top = this.stack.at(-1)) {
|
|
39
|
+
this.stack.pop();
|
|
40
|
+
}
|
|
41
|
+
const parent = this.stack.at(-1);
|
|
42
|
+
const candidate = parent !== void 0 ? `${parent.id}-${base}` : base;
|
|
43
|
+
const id = this.nextSlug(candidate);
|
|
44
|
+
this.stack.push({ depth, id });
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Repeat-numbering on an already-slugified candidate: first occurrence returns
|
|
49
|
+
* `candidate`, later ones `candidate-1`, `candidate-2`, …. Mirrors zfb's
|
|
50
|
+
* `next_slug` — including the empty-string short-circuit (an empty base never
|
|
51
|
+
* advances the counter), so it does NOT re-slugify (the candidate is already a
|
|
52
|
+
* valid slug path).
|
|
53
|
+
*/
|
|
54
|
+
nextSlug(candidate) {
|
|
55
|
+
if (candidate === "") return "";
|
|
56
|
+
const count = this.seen.get(candidate) ?? 0;
|
|
57
|
+
this.seen.set(candidate, count + 1);
|
|
58
|
+
return count === 0 ? candidate : `${candidate}-${count}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function stripInlineMarkdown(raw) {
|
|
62
|
+
return raw.replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/(?<![\w])__([^_]+)__(?![\w])/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/(?<![\w])_([^_]+)_(?![\w])/g, "$1").trim();
|
|
63
|
+
}
|
|
64
|
+
function resolveDepthWindow(rawMin, rawMax) {
|
|
65
|
+
const min = Math.trunc(Number(rawMin));
|
|
66
|
+
const max = Math.trunc(Number(rawMax));
|
|
67
|
+
if (Number.isFinite(min) && Number.isFinite(max) && min >= 2 && min <= max && max <= 4) {
|
|
68
|
+
return { lo: min, hi: max };
|
|
69
|
+
}
|
|
70
|
+
return { lo: 2, hi: 4 };
|
|
71
|
+
}
|
|
72
|
+
function extractHeadings(body, opts) {
|
|
73
|
+
const { lo, hi } = resolveDepthWindow(
|
|
74
|
+
opts?.tocMinDepth ?? 2,
|
|
75
|
+
opts?.tocMaxDepth ?? 4
|
|
76
|
+
);
|
|
77
|
+
const allocator = new SlugAllocator(opts?.strategy ?? "flat");
|
|
78
|
+
const headings = [];
|
|
79
|
+
let codeFenceOpener = null;
|
|
80
|
+
for (const line of body.split("\n")) {
|
|
81
|
+
const trimmed = line.trimStart();
|
|
82
|
+
const fenceMatch = /^([`~]{3,})/.exec(trimmed);
|
|
83
|
+
if (fenceMatch) {
|
|
84
|
+
const fence = fenceMatch[1];
|
|
85
|
+
if (fence === void 0) continue;
|
|
86
|
+
if (codeFenceOpener === null) {
|
|
87
|
+
codeFenceOpener = fence;
|
|
88
|
+
} else if (fence[0] === codeFenceOpener[0] && fence.length >= codeFenceOpener.length) {
|
|
89
|
+
codeFenceOpener = null;
|
|
90
|
+
}
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (codeFenceOpener !== null) continue;
|
|
94
|
+
const match = /^(#{2,6})[ \t]+(.+)$/.exec(line.trim());
|
|
95
|
+
if (!match) continue;
|
|
96
|
+
const hashes = match[1];
|
|
97
|
+
const rawText = match[2];
|
|
98
|
+
if (hashes === void 0 || rawText === void 0) continue;
|
|
99
|
+
const depth = hashes.length;
|
|
100
|
+
const text = stripInlineMarkdown(rawText.trim());
|
|
101
|
+
const slug = allocator.allocate(depth, text);
|
|
102
|
+
if (depth >= lo && depth <= hi) {
|
|
103
|
+
headings.push({ depth, slug, text });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return headings;
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
extractHeadings,
|
|
110
|
+
slugify
|
|
111
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Settings } from "../settings.js";
|
|
2
|
+
/**
|
|
3
|
+
* The i18n surface a factory may read. Parameterizes what `base.ts` used to read
|
|
4
|
+
* off the project's `@/config/i18n` singleton directly, so URL/locale logic moves
|
|
5
|
+
* into the package as pure functions (see `makeUrlHelpers`).
|
|
6
|
+
*
|
|
7
|
+
* `Locale` is kept as a plain `string` at the package boundary — the concrete
|
|
8
|
+
* union (`"en" | "ja" | …`) is a project-specific narrowing the host supplies; the
|
|
9
|
+
* package only needs the structural contract.
|
|
10
|
+
*/
|
|
11
|
+
export interface FactoryI18n {
|
|
12
|
+
/** Default locale code (served from the un-prefixed `/docs/...` routes). */
|
|
13
|
+
defaultLocale: string;
|
|
14
|
+
/** All supported locale codes, default locale first. */
|
|
15
|
+
locales: readonly string[];
|
|
16
|
+
/** Display label for a locale (e.g. `"EN"`, `"日本語"`). */
|
|
17
|
+
getLocaleLabel: (locale: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Translate a UI string key for a locale, falling back to the default locale
|
|
20
|
+
* then the key itself. Optional: factories that emit no UI strings omit it.
|
|
21
|
+
*/
|
|
22
|
+
t?: (key: string, locale?: string) => string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* ALLOWED `{ components }` slots — the host-supplied, project-bound component
|
|
26
|
+
* bindings a factory may inject. This is an **explicit allowlist, NOT an open
|
|
27
|
+
* bag**: every key here is a component the package cannot own because it depends
|
|
28
|
+
* on the host's content collections, settings wiring, or showcase-specific
|
|
29
|
+
* markup. Each slot is documented in `packages/zudo-doc/CLAUDE.md`. Do NOT widen
|
|
30
|
+
* this into a dumping ground — a new slot needs a real cross-package coupling
|
|
31
|
+
* reason and a CLAUDE.md entry. All slots are optional so a factory takes only
|
|
32
|
+
* the ones it needs.
|
|
33
|
+
*
|
|
34
|
+
* Components are typed as the structural `FactoryComponent` (a function
|
|
35
|
+
* returning Preact-renderable output) rather than a concrete signature, so the
|
|
36
|
+
* type stays node-free and Preact-version-agnostic at the boundary.
|
|
37
|
+
*/
|
|
38
|
+
export interface FactoryComponents {
|
|
39
|
+
/** Locale-aware category nav wrapper (reads the project's content collection). */
|
|
40
|
+
CategoryNav?: FactoryComponent;
|
|
41
|
+
/** Locale-aware category-tree nav wrapper. */
|
|
42
|
+
CategoryTreeNav?: FactoryComponent;
|
|
43
|
+
/** Locale-aware site-tree nav wrapper (also used for the demo variant). */
|
|
44
|
+
SiteTreeNav?: FactoryComponent;
|
|
45
|
+
/** HTML-preview wrapper bound to the host's preview config. */
|
|
46
|
+
HtmlPreview?: FactoryComponent;
|
|
47
|
+
/** `<details>` content override. */
|
|
48
|
+
Details?: FactoryComponent;
|
|
49
|
+
/** zfb `<Island>` pass-through (host owns the import so the scanner walks it). */
|
|
50
|
+
Island?: FactoryComponent;
|
|
51
|
+
/** PresetGenerator SSR shell (showcase-only; downstream projects stub it). */
|
|
52
|
+
PresetGenerator?: FactoryComponent;
|
|
53
|
+
}
|
|
54
|
+
/** Any Preact-renderable component — a function returning a VNode/children. */
|
|
55
|
+
export type FactoryComponent = (props: Record<string, unknown>) => unknown;
|
|
56
|
+
/**
|
|
57
|
+
* Opaque per-locale nav-source handle. The host owns the actual content-loader
|
|
58
|
+
* implementation (it reads project content collections, which cannot live in the
|
|
59
|
+
* package); a factory receives this handle and passes it to the package's pure
|
|
60
|
+
* nav builders (`buildNavTree`, sidebar/nav-scope helpers) without knowing its
|
|
61
|
+
* internals. Typed `unknown` on purpose — narrowing belongs to the host stub.
|
|
62
|
+
*/
|
|
63
|
+
export type NavSource = unknown;
|
|
64
|
+
/**
|
|
65
|
+
* The injected context every relocated `pages/lib/*` factory receives.
|
|
66
|
+
*
|
|
67
|
+
* @typeParam S - the host's concrete settings shape (defaults to the package
|
|
68
|
+
* `Settings`). A factory that reads only a subset may accept `Pick<Settings, …>`
|
|
69
|
+
* at its own call site; this context type carries the full object.
|
|
70
|
+
*/
|
|
71
|
+
export interface FactoryContext<S = Settings> {
|
|
72
|
+
/** The host's resolved settings object (single source of config truth). */
|
|
73
|
+
settings: S;
|
|
74
|
+
/** The i18n surface (locales, labels, optional translator). */
|
|
75
|
+
i18n: FactoryI18n;
|
|
76
|
+
/** Host-supplied, project-bound component bindings (explicit allowlist). */
|
|
77
|
+
components: FactoryComponents;
|
|
78
|
+
/** Opaque per-locale nav-source handle passed to the pure nav builders. */
|
|
79
|
+
navSource: NavSource;
|
|
80
|
+
}
|
|
File without changes
|