@takazudo/zudo-doc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/dist/body-foot-util/body-foot-util-area.d.ts +55 -0
  4. package/dist/body-foot-util/body-foot-util-area.js +71 -0
  5. package/dist/body-foot-util/edit-link.d.ts +45 -0
  6. package/dist/body-foot-util/edit-link.js +42 -0
  7. package/dist/body-foot-util/index.d.ts +3 -0
  8. package/dist/body-foot-util/index.js +11 -0
  9. package/dist/breadcrumb/breadcrumb.d.ts +57 -0
  10. package/dist/breadcrumb/breadcrumb.js +113 -0
  11. package/dist/breadcrumb/find-path.d.ts +16 -0
  12. package/dist/breadcrumb/find-path.js +13 -0
  13. package/dist/breadcrumb/index.d.ts +4 -0
  14. package/dist/breadcrumb/index.js +7 -0
  15. package/dist/breadcrumb/types.d.ts +32 -0
  16. package/dist/breadcrumb/types.js +0 -0
  17. package/dist/code-syntax/code-block-enhancer-script.d.ts +3 -0
  18. package/dist/code-syntax/code-block-enhancer-script.js +165 -0
  19. package/dist/code-syntax/code-block-enhancer.d.ts +22 -0
  20. package/dist/code-syntax/code-block-enhancer.js +13 -0
  21. package/dist/code-syntax/index.d.ts +8 -0
  22. package/dist/code-syntax/index.js +29 -0
  23. package/dist/code-syntax/mermaid-init-script.d.ts +51 -0
  24. package/dist/code-syntax/mermaid-init-script.js +225 -0
  25. package/dist/code-syntax/mermaid-init.d.ts +48 -0
  26. package/dist/code-syntax/mermaid-init.js +14 -0
  27. package/dist/code-syntax/tabs-init-script.d.ts +3 -0
  28. package/dist/code-syntax/tabs-init-script.js +106 -0
  29. package/dist/code-syntax/tabs-init.d.ts +24 -0
  30. package/dist/code-syntax/tabs-init.js +10 -0
  31. package/dist/code-syntax/tabs.d.ts +36 -0
  32. package/dist/code-syntax/tabs.js +62 -0
  33. package/dist/content/component-map.d.ts +51 -0
  34. package/dist/content/component-map.js +29 -0
  35. package/dist/content/content-blockquote.d.ts +11 -0
  36. package/dist/content/content-blockquote.js +14 -0
  37. package/dist/content/content-code.d.ts +26 -0
  38. package/dist/content/content-code.js +39 -0
  39. package/dist/content/content-link.d.ts +12 -0
  40. package/dist/content/content-link.js +43 -0
  41. package/dist/content/content-ol.d.ts +11 -0
  42. package/dist/content/content-ol.js +15 -0
  43. package/dist/content/content-paragraph.d.ts +10 -0
  44. package/dist/content/content-paragraph.js +7 -0
  45. package/dist/content/content-strong.d.ts +11 -0
  46. package/dist/content/content-strong.js +14 -0
  47. package/dist/content/content-table.d.ts +11 -0
  48. package/dist/content/content-table.js +14 -0
  49. package/dist/content/content-ul.d.ts +11 -0
  50. package/dist/content/content-ul.js +15 -0
  51. package/dist/content/heading-h2.d.ts +14 -0
  52. package/dist/content/heading-h2.js +18 -0
  53. package/dist/content/heading-h3.d.ts +14 -0
  54. package/dist/content/heading-h3.js +18 -0
  55. package/dist/content/heading-h4.d.ts +14 -0
  56. package/dist/content/heading-h4.js +18 -0
  57. package/dist/content/index.d.ts +13 -0
  58. package/dist/content/index.js +27 -0
  59. package/dist/details/details.d.ts +26 -0
  60. package/dist/details/details.js +10 -0
  61. package/dist/details/index.d.ts +2 -0
  62. package/dist/details/index.js +4 -0
  63. package/dist/doclayout/anchors.d.ts +55 -0
  64. package/dist/doclayout/anchors.js +42 -0
  65. package/dist/doclayout/doc-layout-with-defaults.d.ts +83 -0
  66. package/dist/doclayout/doc-layout-with-defaults.js +159 -0
  67. package/dist/doclayout/doc-layout.d.ts +121 -0
  68. package/dist/doclayout/doc-layout.js +89 -0
  69. package/dist/doclayout/index.d.ts +6 -0
  70. package/dist/doclayout/index.js +17 -0
  71. package/dist/footer/footer.d.ts +42 -0
  72. package/dist/footer/footer.js +79 -0
  73. package/dist/footer/index.d.ts +3 -0
  74. package/dist/footer/index.js +4 -0
  75. package/dist/footer/types.d.ts +58 -0
  76. package/dist/footer/types.js +0 -0
  77. package/dist/head/doc-head.d.ts +33 -0
  78. package/dist/head/doc-head.js +90 -0
  79. package/dist/head/index.d.ts +5 -0
  80. package/dist/head/index.js +8 -0
  81. package/dist/head/og-tags.d.ts +25 -0
  82. package/dist/head/og-tags.js +16 -0
  83. package/dist/head/twitter-card.d.ts +21 -0
  84. package/dist/head/twitter-card.js +14 -0
  85. package/dist/head/types.d.ts +83 -0
  86. package/dist/head/types.js +0 -0
  87. package/dist/header/header.d.ts +158 -0
  88. package/dist/header/header.js +367 -0
  89. package/dist/header/index.d.ts +6 -0
  90. package/dist/header/index.js +18 -0
  91. package/dist/header/nav-active.d.ts +39 -0
  92. package/dist/header/nav-active.js +24 -0
  93. package/dist/header/nav-overflow-script.d.ts +3 -0
  94. package/dist/header/nav-overflow-script.js +169 -0
  95. package/dist/header/right-items.d.ts +38 -0
  96. package/dist/header/right-items.js +30 -0
  97. package/dist/header/types.d.ts +40 -0
  98. package/dist/header/types.js +0 -0
  99. package/dist/html-preview-wrapper/dedent.d.ts +10 -0
  100. package/dist/html-preview-wrapper/dedent.js +16 -0
  101. package/dist/html-preview-wrapper/highlighted-code.d.ts +18 -0
  102. package/dist/html-preview-wrapper/highlighted-code.js +53 -0
  103. package/dist/html-preview-wrapper/html-preview-wrapper.d.ts +60 -0
  104. package/dist/html-preview-wrapper/html-preview-wrapper.js +36 -0
  105. package/dist/html-preview-wrapper/html-preview.d.ts +35 -0
  106. package/dist/html-preview-wrapper/html-preview.js +75 -0
  107. package/dist/html-preview-wrapper/index.d.ts +5 -0
  108. package/dist/html-preview-wrapper/index.js +12 -0
  109. package/dist/html-preview-wrapper/preflight.d.ts +13 -0
  110. package/dist/html-preview-wrapper/preflight.js +108 -0
  111. package/dist/html-preview-wrapper/preview-base.d.ts +29 -0
  112. package/dist/html-preview-wrapper/preview-base.js +127 -0
  113. package/dist/i18n-version/index.d.ts +5 -0
  114. package/dist/i18n-version/index.js +14 -0
  115. package/dist/i18n-version/language-switcher.d.ts +24 -0
  116. package/dist/i18n-version/language-switcher.js +25 -0
  117. package/dist/i18n-version/types.d.ts +43 -0
  118. package/dist/i18n-version/types.js +0 -0
  119. package/dist/i18n-version/version-banner.d.ts +30 -0
  120. package/dist/i18n-version/version-banner.js +21 -0
  121. package/dist/i18n-version/version-switcher.d.ts +112 -0
  122. package/dist/i18n-version/version-switcher.js +157 -0
  123. package/dist/index.d.ts +2 -0
  124. package/dist/index.js +0 -0
  125. package/dist/integrations/claude-resources/escape-for-mdx.d.ts +8 -0
  126. package/dist/integrations/claude-resources/escape-for-mdx.js +131 -0
  127. package/dist/integrations/claude-resources/generate.d.ts +13 -0
  128. package/dist/integrations/claude-resources/generate.js +404 -0
  129. package/dist/integrations/claude-resources/index.d.ts +46 -0
  130. package/dist/integrations/claude-resources/index.js +24 -0
  131. package/dist/integrations/doc-history/index.d.ts +137 -0
  132. package/dist/integrations/doc-history/index.js +138 -0
  133. package/dist/integrations/doc-history/pre-build.d.ts +58 -0
  134. package/dist/integrations/doc-history/pre-build.js +67 -0
  135. package/dist/integrations/llms-txt/dev-middleware.d.ts +40 -0
  136. package/dist/integrations/llms-txt/dev-middleware.js +76 -0
  137. package/dist/integrations/llms-txt/emit.d.ts +22 -0
  138. package/dist/integrations/llms-txt/emit.js +55 -0
  139. package/dist/integrations/llms-txt/generate.d.ts +26 -0
  140. package/dist/integrations/llms-txt/generate.js +36 -0
  141. package/dist/integrations/llms-txt/index.d.ts +7 -0
  142. package/dist/integrations/llms-txt/index.js +27 -0
  143. package/dist/integrations/llms-txt/load.d.ts +51 -0
  144. package/dist/integrations/llms-txt/load.js +83 -0
  145. package/dist/integrations/llms-txt/strip.d.ts +22 -0
  146. package/dist/integrations/llms-txt/strip.js +10 -0
  147. package/dist/integrations/llms-txt/types.d.ts +145 -0
  148. package/dist/integrations/llms-txt/types.js +0 -0
  149. package/dist/integrations/search-index/build-emitter.d.ts +30 -0
  150. package/dist/integrations/search-index/build-emitter.js +15 -0
  151. package/dist/integrations/search-index/collect.d.ts +12 -0
  152. package/dist/integrations/search-index/collect.js +48 -0
  153. package/dist/integrations/search-index/content-files.d.ts +32 -0
  154. package/dist/integrations/search-index/content-files.js +50 -0
  155. package/dist/integrations/search-index/dev-middleware.d.ts +16 -0
  156. package/dist/integrations/search-index/dev-middleware.js +30 -0
  157. package/dist/integrations/search-index/index.d.ts +5 -0
  158. package/dist/integrations/search-index/index.js +14 -0
  159. package/dist/integrations/search-index/types.d.ts +38 -0
  160. package/dist/integrations/search-index/types.js +6 -0
  161. package/dist/metainfo/doc-metainfo.d.ts +50 -0
  162. package/dist/metainfo/doc-metainfo.js +107 -0
  163. package/dist/metainfo/doc-tags.d.ts +66 -0
  164. package/dist/metainfo/doc-tags.js +53 -0
  165. package/dist/metainfo/frontmatter-preview.d.ts +95 -0
  166. package/dist/metainfo/frontmatter-preview.js +55 -0
  167. package/dist/metainfo/index.d.ts +4 -0
  168. package/dist/metainfo/index.js +28 -0
  169. package/dist/nav-indexing/category-nav.d.ts +28 -0
  170. package/dist/nav-indexing/category-nav.js +41 -0
  171. package/dist/nav-indexing/category-tree-nav.d.ts +27 -0
  172. package/dist/nav-indexing/category-tree-nav.js +49 -0
  173. package/dist/nav-indexing/doc-card-grid.d.ts +38 -0
  174. package/dist/nav-indexing/doc-card-grid.js +40 -0
  175. package/dist/nav-indexing/docs-sitemap.d.ts +25 -0
  176. package/dist/nav-indexing/docs-sitemap.js +40 -0
  177. package/dist/nav-indexing/index.d.ts +10 -0
  178. package/dist/nav-indexing/index.js +18 -0
  179. package/dist/nav-indexing/nav-card-grid.d.ts +31 -0
  180. package/dist/nav-indexing/nav-card-grid.js +43 -0
  181. package/dist/nav-indexing/site-tree-nav-demo.d.ts +39 -0
  182. package/dist/nav-indexing/site-tree-nav-demo.js +65 -0
  183. package/dist/nav-indexing/tag-nav.d.ts +38 -0
  184. package/dist/nav-indexing/tag-nav.js +96 -0
  185. package/dist/nav-indexing/types.d.ts +95 -0
  186. package/dist/nav-indexing/types.js +0 -0
  187. package/dist/nav-indexing/versions-page-content.d.ts +29 -0
  188. package/dist/nav-indexing/versions-page-content.js +76 -0
  189. package/dist/page-loading/index.d.ts +2 -0
  190. package/dist/page-loading/index.js +10 -0
  191. package/dist/page-loading/page-loading-overlay.d.ts +35 -0
  192. package/dist/page-loading/page-loading-overlay.js +50 -0
  193. package/dist/sidebar/index.d.ts +3 -0
  194. package/dist/sidebar/index.js +4 -0
  195. package/dist/sidebar/sidebar.d.ts +54 -0
  196. package/dist/sidebar/sidebar.js +35 -0
  197. package/dist/sidebar/types.d.ts +71 -0
  198. package/dist/sidebar/types.js +0 -0
  199. package/dist/sidebar-resizer/index.d.ts +14 -0
  200. package/dist/sidebar-resizer/index.js +165 -0
  201. package/dist/sidebar-resizer/sidebar-resizer-init.d.ts +20 -0
  202. package/dist/sidebar-resizer/sidebar-resizer-init.js +119 -0
  203. package/dist/sidebar-tree/build-tree.d.ts +43 -0
  204. package/dist/sidebar-tree/build-tree.js +127 -0
  205. package/dist/sidebar-tree/category-meta.d.ts +19 -0
  206. package/dist/sidebar-tree/category-meta.js +63 -0
  207. package/dist/sidebar-tree/index.d.ts +3 -0
  208. package/dist/sidebar-tree/index.js +13 -0
  209. package/dist/sidebar-tree/types.d.ts +120 -0
  210. package/dist/sidebar-tree/types.js +0 -0
  211. package/dist/tab-item/index.d.ts +2 -0
  212. package/dist/tab-item/index.js +5 -0
  213. package/dist/tab-item/tab-item.d.ts +38 -0
  214. package/dist/tab-item/tab-item.js +25 -0
  215. package/dist/theme/color-scheme-provider.d.ts +32 -0
  216. package/dist/theme/color-scheme-provider.js +43 -0
  217. package/dist/theme/color-tweak-export-modal.d.ts +20 -0
  218. package/dist/theme/color-tweak-export-modal.js +138 -0
  219. package/dist/theme/design-token-serde.d.ts +136 -0
  220. package/dist/theme/design-token-serde.js +254 -0
  221. package/dist/theme/design-token-tweak-panel.d.ts +11 -0
  222. package/dist/theme/design-token-tweak-panel.js +10 -0
  223. package/dist/theme/design-token-types.d.ts +19 -0
  224. package/dist/theme/design-token-types.js +6 -0
  225. package/dist/theme/iframe-bridge.d.ts +44 -0
  226. package/dist/theme/iframe-bridge.js +70 -0
  227. package/dist/theme/index.d.ts +9 -0
  228. package/dist/theme/index.js +42 -0
  229. package/dist/theme/theme-toggle.d.ts +17 -0
  230. package/dist/theme/theme-toggle.js +91 -0
  231. package/dist/toc/cx.d.ts +16 -0
  232. package/dist/toc/cx.js +22 -0
  233. package/dist/toc/index.d.ts +5 -0
  234. package/dist/toc/index.js +9 -0
  235. package/dist/toc/mobile-toc.d.ts +46 -0
  236. package/dist/toc/mobile-toc.js +88 -0
  237. package/dist/toc/smart-break.d.ts +27 -0
  238. package/dist/toc/smart-break.js +36 -0
  239. package/dist/toc/toc-title.d.ts +10 -0
  240. package/dist/toc/toc-title.js +14 -0
  241. package/dist/toc/toc.d.ts +60 -0
  242. package/dist/toc/toc.js +56 -0
  243. package/dist/toc/types.d.ts +23 -0
  244. package/dist/toc/types.js +0 -0
  245. package/dist/toc/use-active-heading.d.ts +30 -0
  246. package/dist/toc/use-active-heading.js +106 -0
  247. package/dist/transitions/index.d.ts +1 -0
  248. package/dist/transitions/index.js +12 -0
  249. package/dist/transitions/page-events.d.ts +41 -0
  250. package/dist/transitions/page-events.js +20 -0
  251. package/dist/url-normalizer/index.d.ts +1 -0
  252. package/dist/url-normalizer/index.js +6 -0
  253. package/dist/url-normalizer/normalize.d.ts +104 -0
  254. package/dist/url-normalizer/normalize.js +22 -0
  255. package/package.json +186 -0
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Event name fired at the start of a navigation away from the current
3
+ * page. Today resolves to `"zfb:before-preparation"` — dispatched by
4
+ * zfb's client-router on `document` immediately when a same-origin
5
+ * link click is intercepted (Strategy B SPA navigation). Equivalent
6
+ * to "page-loading-begin" / Astro's `astro:before-preparation` in
7
+ * the v2 vocabulary.
8
+ */
9
+ declare const BEFORE_NAVIGATE_EVENT = "zfb:before-preparation";
10
+ /**
11
+ * Event name fired once the new page's `<body>` has been swapped in.
12
+ * Today resolves to `"zfb:after-swap"` — dispatched by zfb's
13
+ * client-router after a Strategy B SPA navigation completes (and on
14
+ * the initial page load, so consumers register one listener and get
15
+ * both first-paint and post-swap behavior). Direct successor to
16
+ * Astro's `astro:page-load`.
17
+ */
18
+ declare const AFTER_NAVIGATE_EVENT = "zfb:after-swap";
19
+ /**
20
+ * Subscribe to "navigation start" — runs `handler` each time the user
21
+ * navigates away from the current page. zfb's `<ClientRouter />`
22
+ * intercepts same-origin link clicks and dispatches
23
+ * `zfb:before-preparation` on `document` before fetching the next
24
+ * page DOM.
25
+ *
26
+ * Returns an unsubscribe function. SSR-safe: if `document` is undefined
27
+ * (server / non-browser host) returns a no-op unsubscribe.
28
+ */
29
+ declare function onBeforeNavigate(handler: () => void): () => void;
30
+ /**
31
+ * Subscribe to "navigation end" — runs `handler` after each page-body
32
+ * swap. Mirrors Astro's `astro:page-load`: fires once on first load,
33
+ * and again on every SPA navigation (zfb's Strategy B client-router
34
+ * dispatches `zfb:after-swap` on the document for both cases).
35
+ *
36
+ * Returns an unsubscribe function. SSR-safe: returns a no-op when
37
+ * called outside a browser.
38
+ */
39
+ declare function onAfterNavigate(handler: () => void): () => void;
40
+
41
+ export { AFTER_NAVIGATE_EVENT, BEFORE_NAVIGATE_EVENT, onAfterNavigate, onBeforeNavigate };
@@ -0,0 +1,20 @@
1
+ const BEFORE_NAVIGATE_EVENT = "zfb:before-preparation";
2
+ const AFTER_NAVIGATE_EVENT = "zfb:after-swap";
3
+ function onBeforeNavigate(handler) {
4
+ if (typeof document === "undefined") return () => {
5
+ };
6
+ document.addEventListener(BEFORE_NAVIGATE_EVENT, handler);
7
+ return () => document.removeEventListener(BEFORE_NAVIGATE_EVENT, handler);
8
+ }
9
+ function onAfterNavigate(handler) {
10
+ if (typeof document === "undefined") return () => {
11
+ };
12
+ document.addEventListener(AFTER_NAVIGATE_EVENT, handler);
13
+ return () => document.removeEventListener(AFTER_NAVIGATE_EVENT, handler);
14
+ }
15
+ export {
16
+ AFTER_NAVIGATE_EVENT,
17
+ BEFORE_NAVIGATE_EVENT,
18
+ onAfterNavigate,
19
+ onBeforeNavigate
20
+ };
@@ -0,0 +1 @@
1
+ export { buildUrl, normalizePathname, shouldSkipNormalization } from './normalize.js';
@@ -0,0 +1,6 @@
1
+ import { buildUrl, normalizePathname, shouldSkipNormalization } from "./normalize.js";
2
+ export {
3
+ buildUrl,
4
+ normalizePathname,
5
+ shouldSkipNormalization
6
+ };
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Build-time URL normalizer for zfb static sites.
3
+ *
4
+ * ## Design rationale
5
+ *
6
+ * Astro's dev server ran trailing-slash normalization as server middleware
7
+ * (`src/middleware-handler.ts`). zfb is purely static — there is no dev
8
+ * middleware layer — so trailing-slash policy splits into two concerns:
9
+ *
10
+ * 1. **Build time** (this module): every route URL emitted during the build
11
+ * (paths() calls, sitemap entries, llms.txt entries, etc.) ends with `/`.
12
+ * `buildUrl()` and `normalizePathname()` enforce that invariant.
13
+ *
14
+ * 2. **Runtime** (host's responsibility): when a visitor navigates to a URL
15
+ * without a trailing slash, the deployment host (e.g. Cloudflare Pages)
16
+ * issues a 301 redirect to the canonical trailing-slash form. For
17
+ * Cloudflare Pages, add one rule to `public/_redirects`:
18
+ *
19
+ * ```
20
+ * # Redirect all non-slash paths to the canonical trailing-slash form.
21
+ * # Place this BEFORE any page-specific rules.
22
+ * /:path /:path/ 301
23
+ * ```
24
+ *
25
+ * By keeping build-time normalisation here and runtime redirects on the host,
26
+ * the framework stays platform-agnostic: swap the host and only the
27
+ * `_redirects` file changes, not this module.
28
+ *
29
+ * ## Skip rules (ported from middleware-handler.ts)
30
+ *
31
+ * The following pathnames bypass normalisation — they are static assets that
32
+ * should never gain a trailing slash:
33
+ *
34
+ * - Already ends with `/` (no-op).
35
+ * - Last path segment contains a file extension whose leading character is a
36
+ * letter, e.g. `.js`, `.css`, `.png`, `.woff2`. The letter check prevents
37
+ * version strings like `v2.0` from being treated as extensions.
38
+ *
39
+ * The Astro-internal prefixes `/_astro/` and `/_image` are preserved in
40
+ * `shouldSkipNormalization()` for completeness, even though zfb uses
41
+ * different internal path shapes. They are harmless and aid forward
42
+ * compatibility with any zfb equivalent that adopts the same conventions.
43
+ */
44
+ /**
45
+ * Build a directory-style URL (always trailing slash) from path segments.
46
+ *
47
+ * Segments are joined with `/`, leading/trailing slashes are collapsed, and
48
+ * the result is wrapped in `/<joined>/`. Empty segments are filtered out.
49
+ * The root case (no segments, or all empty) returns `"/"`.
50
+ *
51
+ * This is the canonical way to construct emitted URLs in zfb pages and
52
+ * integrations — it guarantees the invariant that every generated URL ends
53
+ * with `/`, matching `trailingSlash: "always"` in the legacy Astro build.
54
+ *
55
+ * @example
56
+ * buildUrl("docs", "guides", "getting-started") // "/docs/guides/getting-started/"
57
+ * buildUrl("ja", "docs", "intro") // "/ja/docs/intro/"
58
+ * buildUrl() // "/"
59
+ * buildUrl("", "docs", "") // "/docs/"
60
+ */
61
+ declare function buildUrl(...segments: string[]): string;
62
+ /**
63
+ * Return `true` when `pathname` should NOT receive a trailing slash.
64
+ *
65
+ * The check covers:
66
+ * - Already ends with `/` — already normalised, nothing to do.
67
+ * - Astro-internal prefixes `/_astro/` and `/_image` — kept for forward
68
+ * compatibility; these paths are never part of the content URL space.
69
+ * - The last segment looks like a filename: its extension starts with a
70
+ * letter (`/assets/app.js`, `/images/logo.png`, `/fonts/inter.woff2`).
71
+ * The letter constraint prevents version strings like `/docs/v2.0` from
72
+ * being mistakenly treated as a static-asset path.
73
+ *
74
+ * @example
75
+ * shouldSkipNormalization("/docs/guide/") // true (already has slash)
76
+ * shouldSkipNormalization("/assets/app.js") // true (file extension)
77
+ * shouldSkipNormalization("/_astro/chunk.abc.js") // true (internal prefix)
78
+ * shouldSkipNormalization("/docs/guide") // false (needs trailing slash)
79
+ * shouldSkipNormalization("/docs/v2.0") // false (number after dot → not an extension)
80
+ */
81
+ declare function shouldSkipNormalization(pathname: string): boolean;
82
+ /**
83
+ * Return `pathname` with a trailing slash appended if needed.
84
+ *
85
+ * Passes through pathnames that already satisfy `shouldSkipNormalization()`.
86
+ * Query strings are preserved intact (the URL object is not involved here —
87
+ * pass only the pathname).
88
+ *
89
+ * **Important:** this operates on the *pathname* portion only. For a full
90
+ * URL with query string or fragment, split out the pathname first:
91
+ *
92
+ * ```ts
93
+ * const url = new URL(rawUrl);
94
+ * const normalized = normalizePathname(url.pathname) + url.search;
95
+ * ```
96
+ *
97
+ * @example
98
+ * normalizePathname("/docs/guide") // "/docs/guide/"
99
+ * normalizePathname("/docs/guide/") // "/docs/guide/" (no-op)
100
+ * normalizePathname("/assets/app.js") // "/assets/app.js" (skipped)
101
+ */
102
+ declare function normalizePathname(pathname: string): string;
103
+
104
+ export { buildUrl, normalizePathname, shouldSkipNormalization };
@@ -0,0 +1,22 @@
1
+ function buildUrl(...segments) {
2
+ const joined = segments.filter((s) => s !== "").join("/").replace(/^\/+/, "").replace(/\/+$/, "");
3
+ return joined === "" ? "/" : `/${joined}/`;
4
+ }
5
+ function shouldSkipNormalization(pathname) {
6
+ if (pathname.endsWith("/")) return true;
7
+ if (pathname.startsWith("/_astro/") || pathname.startsWith("/_image")) {
8
+ return true;
9
+ }
10
+ const lastSegment = pathname.split("/").pop() ?? "";
11
+ if (/\.[a-zA-Z]\w*$/.test(lastSegment)) return true;
12
+ return false;
13
+ }
14
+ function normalizePathname(pathname) {
15
+ if (shouldSkipNormalization(pathname)) return pathname;
16
+ return pathname + "/";
17
+ }
18
+ export {
19
+ buildUrl,
20
+ normalizePathname,
21
+ shouldSkipNormalization
22
+ };
package/package.json ADDED
@@ -0,0 +1,186 @@
1
+ {
2
+ "name": "@takazudo/zudo-doc",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "zudo-doc framework primitives layer that sits on top of zfb's engine — sidebar, theme, TOC, breadcrumb, layouts, head injection, View Transitions, SSR-skip wrappers (per ADR-003).",
6
+ "license": "MIT",
7
+ "author": "Takeshi Takatsudo",
8
+ "homepage": "https://zudo-doc.takazudomodular.com",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/zudolab/zudo-doc.git",
12
+ "directory": "packages/zudo-doc"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/zudolab/zudo-doc/issues"
16
+ },
17
+ "keywords": [
18
+ "zudo-doc",
19
+ "documentation",
20
+ "framework",
21
+ "mdx",
22
+ "preact",
23
+ "zfb"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public",
27
+ "provenance": true
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./sidebar-tree": {
35
+ "types": "./dist/sidebar-tree/index.d.ts",
36
+ "default": "./dist/sidebar-tree/index.js"
37
+ },
38
+ "./theme": {
39
+ "types": "./dist/theme/index.d.ts",
40
+ "default": "./dist/theme/index.js"
41
+ },
42
+ "./theme/color-scheme-provider": {
43
+ "types": "./dist/theme/color-scheme-provider.d.ts",
44
+ "default": "./dist/theme/color-scheme-provider.js"
45
+ },
46
+ "./toc": {
47
+ "types": "./dist/toc/index.d.ts",
48
+ "default": "./dist/toc/index.js"
49
+ },
50
+ "./breadcrumb": {
51
+ "types": "./dist/breadcrumb/index.d.ts",
52
+ "default": "./dist/breadcrumb/index.js"
53
+ },
54
+ "./header": {
55
+ "types": "./dist/header/index.d.ts",
56
+ "default": "./dist/header/index.js"
57
+ },
58
+ "./footer": {
59
+ "types": "./dist/footer/index.d.ts",
60
+ "default": "./dist/footer/index.js"
61
+ },
62
+ "./sidebar": {
63
+ "types": "./dist/sidebar/index.d.ts",
64
+ "default": "./dist/sidebar/index.js"
65
+ },
66
+ "./sidebar/types": {
67
+ "types": "./dist/sidebar/types.d.ts",
68
+ "default": "./dist/sidebar/types.js"
69
+ },
70
+ "./i18n-version": {
71
+ "types": "./dist/i18n-version/index.d.ts",
72
+ "default": "./dist/i18n-version/index.js"
73
+ },
74
+ "./page-loading": {
75
+ "types": "./dist/page-loading/index.d.ts",
76
+ "default": "./dist/page-loading/index.js"
77
+ },
78
+ "./tab-item": {
79
+ "types": "./dist/tab-item/index.d.ts",
80
+ "default": "./dist/tab-item/index.js"
81
+ },
82
+ "./code-syntax": {
83
+ "types": "./dist/code-syntax/index.d.ts",
84
+ "default": "./dist/code-syntax/index.js"
85
+ },
86
+ "./body-foot-util": {
87
+ "types": "./dist/body-foot-util/index.d.ts",
88
+ "default": "./dist/body-foot-util/index.js"
89
+ },
90
+ "./sidebar-resizer": {
91
+ "types": "./dist/sidebar-resizer/index.d.ts",
92
+ "default": "./dist/sidebar-resizer/index.js"
93
+ },
94
+ "./doclayout": {
95
+ "types": "./dist/doclayout/index.d.ts",
96
+ "default": "./dist/doclayout/index.js"
97
+ },
98
+ "./head": {
99
+ "types": "./dist/head/index.d.ts",
100
+ "default": "./dist/head/index.js"
101
+ },
102
+ "./transitions": {
103
+ "types": "./dist/transitions/index.d.ts",
104
+ "default": "./dist/transitions/index.js"
105
+ },
106
+ "./integrations/doc-history": {
107
+ "types": "./dist/integrations/doc-history/index.d.ts",
108
+ "default": "./dist/integrations/doc-history/index.js"
109
+ },
110
+ "./integrations/llms-txt": {
111
+ "types": "./dist/integrations/llms-txt/index.d.ts",
112
+ "default": "./dist/integrations/llms-txt/index.js"
113
+ },
114
+ "./integrations/search-index": {
115
+ "types": "./dist/integrations/search-index/index.d.ts",
116
+ "default": "./dist/integrations/search-index/index.js"
117
+ },
118
+ "./integrations/claude-resources": {
119
+ "types": "./dist/integrations/claude-resources/index.d.ts",
120
+ "default": "./dist/integrations/claude-resources/index.js"
121
+ },
122
+ "./content": {
123
+ "types": "./dist/content/index.d.ts",
124
+ "default": "./dist/content/index.js"
125
+ },
126
+ "./nav-indexing": {
127
+ "types": "./dist/nav-indexing/index.d.ts",
128
+ "default": "./dist/nav-indexing/index.js"
129
+ },
130
+ "./nav-indexing/types": {
131
+ "types": "./dist/nav-indexing/types.d.ts",
132
+ "default": "./dist/nav-indexing/types.js"
133
+ },
134
+ "./metainfo": {
135
+ "types": "./dist/metainfo/index.d.ts",
136
+ "default": "./dist/metainfo/index.js"
137
+ },
138
+ "./html-preview-wrapper": {
139
+ "types": "./dist/html-preview-wrapper/index.d.ts",
140
+ "default": "./dist/html-preview-wrapper/index.js"
141
+ },
142
+ "./details": {
143
+ "types": "./dist/details/index.d.ts",
144
+ "default": "./dist/details/index.js"
145
+ },
146
+ "./url-normalizer": {
147
+ "types": "./dist/url-normalizer/index.d.ts",
148
+ "default": "./dist/url-normalizer/index.js"
149
+ }
150
+ },
151
+ "files": [
152
+ "dist",
153
+ "README.md"
154
+ ],
155
+ "peerDependencies": {
156
+ "preact": "^10.29.1",
157
+ "@takazudo/zfb": "^0.1.0-next.6",
158
+ "@takazudo/zfb-runtime": "^0.1.0-next.6",
159
+ "@takazudo/zudo-doc-history-server": "^0.1.0"
160
+ },
161
+ "peerDependenciesMeta": {
162
+ "@takazudo/zudo-doc-history-server": {
163
+ "optional": true
164
+ }
165
+ },
166
+ "dependencies": {
167
+ "gray-matter": "^4.0.3"
168
+ },
169
+ "devDependencies": {
170
+ "@types/node": "^25.3.5",
171
+ "cross-env": "^7.0.3",
172
+ "preact": "^10.29.1",
173
+ "preact-render-to-string": "^6.6.6",
174
+ "tsup": "^8.0.0",
175
+ "typescript": "^5.0.0",
176
+ "vitest": "^3.0.0",
177
+ "@takazudo/zfb": "0.1.0-next.6",
178
+ "@takazudo/zfb-runtime": "0.1.0-next.6"
179
+ },
180
+ "scripts": {
181
+ "build": "cross-env NODE_OPTIONS=--max-old-space-size=4096 tsup",
182
+ "dev": "tsup --watch",
183
+ "test": "vitest run --config vitest.config.ts",
184
+ "typecheck": "tsc --noEmit"
185
+ }
186
+ }