@takazudo/zudo-doc 10.0.3 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/asset-index-page/index.js +1 -1
- package/dist/asset-page/index.js +1 -1
- package/dist/asset-path/index.d.ts +2 -0
- package/dist/asset-path/index.js +1 -0
- package/dist/catalog.js +1 -1
- package/dist/chrome/derive.js +14 -2
- package/dist/compiled.css +178 -30
- package/dist/config-assertions/index.d.ts +54 -0
- package/dist/config-assertions/index.js +205 -0
- package/dist/config.d.ts +12 -9
- package/dist/config.js +8 -0
- package/dist/content/index.d.ts +1 -0
- package/dist/content/index.js +2 -0
- package/dist/content/wide-section-heading.d.ts +12 -0
- package/dist/content/wide-section-heading.js +8 -0
- package/dist/doc-body-end-islands/index.d.ts +0 -7
- package/dist/doc-body-end-islands/index.js +0 -6
- package/dist/doc-card-nav/index.d.ts +78 -0
- package/dist/doc-card-nav/index.js +82 -0
- package/dist/doc-card-nav/slug.d.ts +6 -0
- package/dist/doc-card-nav/slug.js +6 -0
- package/dist/doc-page-renderer/index.d.ts +1 -0
- package/dist/doc-page-renderer/index.js +2 -0
- package/dist/doc-page-shell/index.d.ts +3 -0
- package/dist/doc-page-shell/index.js +4 -1
- package/dist/docs-schema/index.d.ts +2 -0
- package/dist/docs-schema/index.js +9 -0
- package/dist/features.css +201 -0
- package/dist/frontmatter-preview-defaults/index.js +3 -1
- package/dist/head-with-defaults/index.d.ts +11 -0
- package/dist/head-with-defaults/index.js +15 -3
- package/dist/home-hero/index.d.ts +36 -0
- package/dist/home-hero/index.js +128 -0
- package/dist/home-page/index.js +149 -58
- package/dist/i18n-defaults/index.js +8 -0
- package/dist/mcp/constants.d.ts +11 -0
- package/dist/mcp/constants.js +20 -0
- package/dist/mcp/discovery.d.ts +45 -0
- package/dist/mcp/discovery.js +138 -0
- package/dist/mcp/handler.js +4 -2
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.js +37 -1
- package/dist/nav-indexing/doc-card-grid.d.ts +6 -0
- package/dist/nav-indexing/doc-card-grid.js +26 -16
- package/dist/plugins/internal/llms-txt/dev-middleware.js +5 -1
- package/dist/plugins/internal/llms-txt/emit.js +5 -1
- package/dist/plugins/internal/llms-txt/generate.d.ts +2 -0
- package/dist/plugins/internal/llms-txt/generate.js +3 -0
- package/dist/plugins/routes.js +6 -1
- package/dist/preset.d.ts +4 -1
- package/dist/preset.js +8 -0
- package/dist/robots.d.ts +14 -0
- package/dist/robots.js +22 -4
- package/dist/routes/404.js +1 -1
- package/dist/routes/ai-catalog.d.ts +5 -0
- package/dist/routes/ai-catalog.js +28 -0
- package/dist/routes/mcp-server-card.d.ts +5 -0
- package/dist/routes/mcp-server-card.js +24 -0
- package/dist/settings-defaults.js +1 -1
- package/dist/settings.d.ts +102 -6
- package/dist/sidebar/client-data.d.ts +1 -1
- package/dist/sidebar/client-data.js +2 -0
- package/dist/sidebar/types.d.ts +4 -0
- package/dist/sidebar-tree/build-tree.js +1 -0
- package/dist/sidebar-tree/types.d.ts +4 -0
- package/dist/site-schema/nav-tree.js +2 -0
- package/dist/site-schema/types.d.ts +3 -0
- package/dist/site-tree-nav/index.d.ts +18 -0
- package/dist/site-tree-nav/index.js +18 -3
- package/dist/site-tree-nav/normalize-island-props.d.ts +6 -0
- package/dist/site-tree-nav/normalize-island-props.js +15 -0
- package/dist/site-tree-nav-island/count.d.ts +3 -0
- package/dist/site-tree-nav-island/count.js +11 -0
- package/dist/site-tree-nav-island/index.d.ts +22 -2
- package/dist/site-tree-nav-island/index.js +272 -221
- package/dist/tag-pages/index.d.ts +1 -0
- package/dist/tag-pages/index.js +2 -2
- package/dist/theme-packs/bauhaus/meta.json +1 -1
- package/dist/theme-packs/bauhaus/pack.css +2 -2
- package/dist/theme-packs/beacon/meta.json +1 -1
- package/dist/theme-packs/beacon/pack.css +0 -15
- package/dist/theme-packs/eink/meta.json +1 -1
- package/dist/theme-packs/eink/pack.css +1 -14
- package/dist/theme.css +0 -16
- package/dist/versions-page/index.d.ts +1 -0
- package/dist/versions-page/index.js +1 -1
- package/dist/wind.json +4 -6
- package/eject/sidebar/client-data.ts +3 -1
- package/eject/sidebar/types.ts +4 -0
- package/eject/site-tree-nav-island/count.ts +11 -0
- package/eject/site-tree-nav-island/index.tsx +359 -256
- package/package.json +19 -7
- package/routes-src/404.tsx +1 -1
- package/routes-src/ai-catalog.tsx +26 -0
- package/routes-src/mcp-server-card.tsx +21 -0
- package/dist/find-in-page/find-bar.d.ts +0 -11
- package/dist/find-in-page/find-bar.js +0 -103
- package/dist/find-in-page/find-in-page.d.ts +0 -17
- package/dist/find-in-page/find-in-page.js +0 -131
- package/dist/find-in-page/index.d.ts +0 -5
- package/dist/find-in-page/index.js +0 -52
|
@@ -9,13 +9,7 @@ import {
|
|
|
9
9
|
} from "@takazudo/zfb/zudo-react";
|
|
10
10
|
import type { SidebarNavNode } from "../sidebar/types.js";
|
|
11
11
|
import type { ResolvedDateFormats } from "../settings.js";
|
|
12
|
-
import {
|
|
13
|
-
INDENT,
|
|
14
|
-
connectorLeft,
|
|
15
|
-
connectorLabelStart,
|
|
16
|
-
ConnectorLines,
|
|
17
|
-
CategoryLinkIcon,
|
|
18
|
-
} from "../tree-nav-shared/index.js";
|
|
12
|
+
import { CategoryLinkIcon } from "../tree-nav-shared/index.js";
|
|
19
13
|
import { ChevronRight } from "../icons/index.js";
|
|
20
14
|
import {
|
|
21
15
|
formatDate,
|
|
@@ -27,21 +21,31 @@ import {
|
|
|
27
21
|
} from "../note-tray-model/index.js";
|
|
28
22
|
import { formatMonthDay } from "../format-date/index.js";
|
|
29
23
|
import { initialCategoryOpenState, toggleCategoryOpenState } from "./state.js";
|
|
24
|
+
import { countCategoryDocuments } from "./count.js";
|
|
30
25
|
|
|
31
|
-
//
|
|
32
|
-
|
|
26
|
+
// Tree geometry (slot, rail axis, indent, first-line midpoint, lead-in/crop
|
|
27
|
+
// switch) is authored once as `.zd-site-tree*` rules in `features.css`; this
|
|
28
|
+
// file only emits the hook classes and data attributes those rules read.
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
/** Standard keeps the established 18rem grid; described cards need ~22rem. */
|
|
31
|
+
const GRID_COLUMNS = {
|
|
32
|
+
default: "repeat(auto-fill, minmax(min(18rem, 100%), 1fr))",
|
|
33
|
+
described: "repeat(auto-fit, minmax(min(22rem, 100%), 1fr))",
|
|
34
|
+
} as const;
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
/** Pluralized "N documents" templates for the described variant; `{count}` is replaced. */
|
|
37
|
+
export interface SiteTreeNavCountLabels {
|
|
38
|
+
one: string;
|
|
39
|
+
other: string;
|
|
43
40
|
}
|
|
44
41
|
|
|
42
|
+
const DEFAULT_COUNT_LABELS: SiteTreeNavCountLabels = {
|
|
43
|
+
one: "{count} document",
|
|
44
|
+
other: "{count} documents",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type SiteTreeNavVariant = "default" | "described";
|
|
48
|
+
|
|
45
49
|
function reorderTree(tree: SidebarNavNode[], order: string[]): SidebarNavNode[] {
|
|
46
50
|
const map = new Map(tree.map((node) => [node.slug, node]));
|
|
47
51
|
const ordered: SidebarNavNode[] = [];
|
|
@@ -59,6 +63,23 @@ function reorderTree(tree: SidebarNavNode[], order: string[]): SidebarNavNode[]
|
|
|
59
63
|
return ordered;
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
/** DOM-id-safe, deterministic encoding of a nav slug. */
|
|
67
|
+
function slugToId(slug: string): string {
|
|
68
|
+
if (slug === "") return "root";
|
|
69
|
+
return slug.replace(/[^A-Za-z0-9_-]/g, (c) => `_${c.codePointAt(0)!.toString(16)}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function formatCount(count: number, locale: string, labels: SiteTreeNavCountLabels): string {
|
|
73
|
+
let category = "other";
|
|
74
|
+
try {
|
|
75
|
+
category = new Intl.PluralRules(locale).select(count);
|
|
76
|
+
} catch {
|
|
77
|
+
category = count === 1 ? "one" : "other";
|
|
78
|
+
}
|
|
79
|
+
const template = category === "one" ? labels.one : labels.other;
|
|
80
|
+
return template.replaceAll("{count}", String(count));
|
|
81
|
+
}
|
|
82
|
+
|
|
62
83
|
export interface SiteTreeNavProps {
|
|
63
84
|
tree: SidebarNavNode[];
|
|
64
85
|
ariaLabel?: string;
|
|
@@ -66,7 +87,7 @@ export interface SiteTreeNavProps {
|
|
|
66
87
|
categoryIgnore?: string[];
|
|
67
88
|
/** Exact full category slugs at any depth that should start collapsed. */
|
|
68
89
|
initiallyCollapsedCategorySlugs?: string[];
|
|
69
|
-
/** Locale used by dated note-tray rows. */
|
|
90
|
+
/** Locale used by dated note-tray rows and the described document count. */
|
|
70
91
|
locale?: string;
|
|
71
92
|
/**
|
|
72
93
|
* Per-role date patterns already resolved for the page's locale, serialized
|
|
@@ -77,6 +98,29 @@ export interface SiteTreeNavProps {
|
|
|
77
98
|
dateFormats?: ResolvedDateFormats;
|
|
78
99
|
/** @deprecated — no longer rendered (created date only). */
|
|
79
100
|
updatedLabel?: string;
|
|
101
|
+
/**
|
|
102
|
+
* `"described"` shows available category/document descriptions and each
|
|
103
|
+
* category's document count in a ~22rem-column grid; a lone category splits
|
|
104
|
+
* into summary + tree columns when its own box is wide enough. Omitted (or
|
|
105
|
+
* `"default"`) keeps the standard compact grid.
|
|
106
|
+
*/
|
|
107
|
+
variant?: SiteTreeNavVariant;
|
|
108
|
+
/** Described-variant count templates (`{count}` placeholder). English when omitted. */
|
|
109
|
+
countLabels?: SiteTreeNavCountLabels;
|
|
110
|
+
/**
|
|
111
|
+
* Prefix for the disclosure-target ids. Give distinct values when several
|
|
112
|
+
* site trees share one page. @default "zd-site-tree"
|
|
113
|
+
*/
|
|
114
|
+
idPrefix?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface TreeContext {
|
|
118
|
+
initiallyCollapsed: ReadonlySet<string>;
|
|
119
|
+
idPrefix: string;
|
|
120
|
+
described: boolean;
|
|
121
|
+
locale: string;
|
|
122
|
+
dateFormats?: ResolvedDateFormats;
|
|
123
|
+
updatedLabel: string;
|
|
80
124
|
}
|
|
81
125
|
|
|
82
126
|
export function SiteTreeNav({
|
|
@@ -88,6 +132,9 @@ export function SiteTreeNav({
|
|
|
88
132
|
locale = "en",
|
|
89
133
|
dateFormats,
|
|
90
134
|
updatedLabel = "Updated",
|
|
135
|
+
variant = "default",
|
|
136
|
+
countLabels = DEFAULT_COUNT_LABELS,
|
|
137
|
+
idPrefix = "zd-site-tree",
|
|
91
138
|
}: SiteTreeNavProps) {
|
|
92
139
|
let processedTree = tree;
|
|
93
140
|
if (categoryIgnore) {
|
|
@@ -98,227 +145,349 @@ export function SiteTreeNav({
|
|
|
98
145
|
processedTree = reorderTree(processedTree, categoryOrder);
|
|
99
146
|
}
|
|
100
147
|
|
|
148
|
+
const described = variant === "described";
|
|
101
149
|
// Every value used to seed the tree is part of the JSON-serializable island
|
|
102
150
|
// props. There is no browser storage or location read during setup.
|
|
103
151
|
const roots = signal(processedTree);
|
|
104
|
-
const
|
|
152
|
+
const visibleRootCount = processedTree.filter(
|
|
153
|
+
(node) => node.shape !== "note-tray" || getNoteTrayItems(node).length > 0,
|
|
154
|
+
).length;
|
|
155
|
+
const context: TreeContext = {
|
|
156
|
+
initiallyCollapsed: new Set(initiallyCollapsedCategorySlugs),
|
|
157
|
+
idPrefix,
|
|
158
|
+
described,
|
|
159
|
+
locale,
|
|
160
|
+
dateFormats,
|
|
161
|
+
updatedLabel,
|
|
162
|
+
};
|
|
105
163
|
|
|
106
164
|
return (
|
|
107
165
|
<nav
|
|
108
166
|
aria-label={ariaLabel}
|
|
109
167
|
data-site-nav
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}}
|
|
168
|
+
data-variant={described ? "described" : "default"}
|
|
169
|
+
class="zd-site-tree grid gap-vsp-md"
|
|
170
|
+
style={{ "grid-template-columns": GRID_COLUMNS[described ? "described" : "default"] }}
|
|
114
171
|
>
|
|
115
172
|
<For each={roots} by={(node) => node.slug}>
|
|
116
|
-
{(node
|
|
117
|
-
|
|
118
|
-
|
|
173
|
+
{(node) => (
|
|
174
|
+
<Show
|
|
175
|
+
when={computed(
|
|
176
|
+
() =>
|
|
177
|
+
node.value.shape !== "note-tray" ||
|
|
178
|
+
getNoteTrayItems(node.value).length > 0,
|
|
179
|
+
)}
|
|
180
|
+
>
|
|
181
|
+
{() => (
|
|
182
|
+
<RootCard
|
|
183
|
+
node={node}
|
|
184
|
+
context={context}
|
|
185
|
+
single={visibleRootCount === 1}
|
|
186
|
+
countLabels={countLabels}
|
|
187
|
+
/>
|
|
188
|
+
)}
|
|
189
|
+
</Show>
|
|
190
|
+
)}
|
|
191
|
+
</For>
|
|
192
|
+
</nav>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
SiteTreeNav.displayName = "SiteTreeNav";
|
|
196
|
+
|
|
197
|
+
function DisclosureButton({
|
|
198
|
+
open,
|
|
199
|
+
label,
|
|
200
|
+
controls,
|
|
201
|
+
onToggle,
|
|
202
|
+
}: {
|
|
203
|
+
open: ReadonlySignal<boolean>;
|
|
204
|
+
label: ReadonlySignal<string>;
|
|
205
|
+
controls: string;
|
|
206
|
+
onToggle: () => void;
|
|
207
|
+
}) {
|
|
208
|
+
return (
|
|
209
|
+
<button
|
|
210
|
+
type="button"
|
|
211
|
+
on:click={onToggle}
|
|
212
|
+
class="zd-site-tree-toggle flex shrink-0 items-center justify-center border border-muted text-muted hover:text-accent hover:underline focus:underline focus-visible:text-accent"
|
|
213
|
+
aria-expanded={computed(() => (open.value ? "true" : "false"))}
|
|
214
|
+
aria-label={computed(() => `${open.value ? "Collapse" : "Expand"} ${label.value}`)}
|
|
215
|
+
aria-controls={controls}
|
|
216
|
+
>
|
|
217
|
+
<span
|
|
218
|
+
class="inline-flex transition-transform duration-150"
|
|
219
|
+
aria-hidden="true"
|
|
220
|
+
style={computed(() => `transform:rotate(${open.value ? "90deg" : "0deg"})`)}
|
|
221
|
+
>
|
|
222
|
+
<ChevronRight class="h-icon-xs w-icon-xs" />
|
|
223
|
+
</span>
|
|
224
|
+
</button>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function RootCard({
|
|
229
|
+
node,
|
|
230
|
+
context,
|
|
231
|
+
single,
|
|
232
|
+
countLabels,
|
|
233
|
+
}: {
|
|
234
|
+
node: ReadonlySignal<SidebarNavNode>;
|
|
235
|
+
context: TreeContext;
|
|
236
|
+
single: boolean;
|
|
237
|
+
countLabels: SiteTreeNavCountLabels;
|
|
238
|
+
}) {
|
|
239
|
+
const { described } = context;
|
|
240
|
+
const hasChildren = node.value.children.length > 0;
|
|
241
|
+
const open = signal(
|
|
242
|
+
initialCategoryOpenState(context.initiallyCollapsed.has(node.value.slug)),
|
|
243
|
+
);
|
|
244
|
+
const toggle = () => {
|
|
245
|
+
open.value = toggleCategoryOpenState(open.value);
|
|
246
|
+
};
|
|
247
|
+
const label = computed(() => node.value.label);
|
|
248
|
+
const href = computed(() => node.value.href);
|
|
249
|
+
const description = computed(() => node.value.description ?? "");
|
|
250
|
+
const controls = `${context.idPrefix}-${slugToId(node.value.slug)}`;
|
|
251
|
+
const isNoteTray = node.value.shape === "note-tray";
|
|
252
|
+
const splitCandidate = described && single && hasChildren;
|
|
253
|
+
const labelClass =
|
|
254
|
+
"zd-site-tree-label flex min-w-0 flex-1 items-start text-left font-semibold text-fg break-words hover:text-accent hover:underline focus:underline focus-visible:text-accent";
|
|
255
|
+
const labelContent = (
|
|
256
|
+
<>
|
|
257
|
+
<span class="zd-site-tree-marker flex shrink-0 items-center justify-center" aria-hidden="true">
|
|
258
|
+
<CategoryLinkIcon class="w-[18px]" />
|
|
259
|
+
</span>
|
|
260
|
+
<span class="min-w-0">{label}</span>
|
|
261
|
+
</>
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<div
|
|
266
|
+
class="zd-site-tree-card min-w-0 border border-muted bg-bg"
|
|
267
|
+
data-site-tree-root={node.value.slug}
|
|
268
|
+
{...(described ? { "data-described": "" } : {})}
|
|
269
|
+
>
|
|
270
|
+
{node.value.coverHref ? (
|
|
271
|
+
<img
|
|
272
|
+
src={node.value.coverHref}
|
|
273
|
+
alt=""
|
|
274
|
+
width="1200"
|
|
275
|
+
height="630"
|
|
276
|
+
loading="lazy"
|
|
277
|
+
decoding="async"
|
|
278
|
+
class="zd-site-nav-cover"
|
|
279
|
+
/>
|
|
280
|
+
) : null}
|
|
281
|
+
<div
|
|
282
|
+
class="zd-site-tree-body"
|
|
283
|
+
{...(splitCandidate
|
|
284
|
+
? { "data-split": computed(() => (open.value ? "true" : "false")) }
|
|
285
|
+
: {})}
|
|
286
|
+
>
|
|
287
|
+
<div class="min-w-0">
|
|
288
|
+
<div class="zd-site-tree-head flex items-start justify-between gap-hsp-xs text-small">
|
|
119
289
|
<Show
|
|
120
|
-
when={computed(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
290
|
+
when={computed(() => Boolean(href.value))}
|
|
291
|
+
fallback={() =>
|
|
292
|
+
hasChildren ? (
|
|
293
|
+
<button
|
|
294
|
+
type="button"
|
|
295
|
+
on:click={toggle}
|
|
296
|
+
class={labelClass}
|
|
297
|
+
aria-expanded={computed(() => (open.value ? "true" : "false"))}
|
|
298
|
+
aria-controls={controls}
|
|
299
|
+
>
|
|
300
|
+
{labelContent}
|
|
301
|
+
</button>
|
|
302
|
+
) : (
|
|
303
|
+
<span class={labelClass}>{labelContent}</span>
|
|
304
|
+
)
|
|
305
|
+
}
|
|
125
306
|
>
|
|
126
307
|
{() => (
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
fallback={() => (
|
|
131
|
-
<LeafNode node={node} depth={0} isLast={isLast} />
|
|
132
|
-
)}
|
|
133
|
-
>
|
|
134
|
-
{() => (
|
|
135
|
-
<CategoryNode
|
|
136
|
-
node={node}
|
|
137
|
-
depth={0}
|
|
138
|
-
isLast={isLast}
|
|
139
|
-
initiallyCollapsedCategorySlugs={initiallyCollapsed}
|
|
140
|
-
locale={locale}
|
|
141
|
-
dateFormats={dateFormats}
|
|
142
|
-
updatedLabel={updatedLabel}
|
|
143
|
-
/>
|
|
144
|
-
)}
|
|
145
|
-
</Show>
|
|
146
|
-
</div>
|
|
308
|
+
<a href={computed(() => href.value ?? "")} class={labelClass}>
|
|
309
|
+
{labelContent}
|
|
310
|
+
</a>
|
|
147
311
|
)}
|
|
148
312
|
</Show>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
313
|
+
{hasChildren && (
|
|
314
|
+
<DisclosureButton open={open} label={label} controls={controls} onToggle={toggle} />
|
|
315
|
+
)}
|
|
316
|
+
</div>
|
|
317
|
+
{described && (
|
|
318
|
+
<>
|
|
319
|
+
<Show when={computed(() => description.value.length > 0)}>
|
|
320
|
+
{() => (
|
|
321
|
+
<p class="mt-vsp-xs text-small text-muted break-words" data-site-tree-description>
|
|
322
|
+
{description}
|
|
323
|
+
</p>
|
|
324
|
+
)}
|
|
325
|
+
</Show>
|
|
326
|
+
<p class="mt-vsp-2xs text-caption text-muted" data-site-tree-count>
|
|
327
|
+
{computed(() =>
|
|
328
|
+
formatCount(countCategoryDocuments(node.value), context.locale, countLabels),
|
|
329
|
+
)}
|
|
330
|
+
</p>
|
|
331
|
+
</>
|
|
332
|
+
)}
|
|
333
|
+
</div>
|
|
334
|
+
{hasChildren && (
|
|
335
|
+
<div
|
|
336
|
+
id={controls}
|
|
337
|
+
class="min-w-0"
|
|
338
|
+
hidden={computed(() => !open.value)}
|
|
339
|
+
>
|
|
340
|
+
<Show when={open}>
|
|
341
|
+
{() =>
|
|
342
|
+
isNoteTray ? (
|
|
343
|
+
<NoteTrayNodeList
|
|
344
|
+
node={node}
|
|
345
|
+
locale={context.locale}
|
|
346
|
+
dateFormats={context.dateFormats}
|
|
347
|
+
updatedLabel={context.updatedLabel}
|
|
348
|
+
/>
|
|
349
|
+
) : (
|
|
350
|
+
<NodeList
|
|
351
|
+
nodes={computed(() => node.value.children)}
|
|
352
|
+
context={context}
|
|
353
|
+
root={true}
|
|
354
|
+
/>
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
</Show>
|
|
358
|
+
</div>
|
|
359
|
+
)}
|
|
360
|
+
</div>
|
|
361
|
+
</div>
|
|
153
362
|
);
|
|
154
363
|
}
|
|
155
|
-
SiteTreeNav.displayName = "SiteTreeNav";
|
|
156
364
|
|
|
157
365
|
function NodeList({
|
|
158
366
|
nodes,
|
|
159
|
-
|
|
160
|
-
|
|
367
|
+
context,
|
|
368
|
+
root,
|
|
161
369
|
}: {
|
|
162
370
|
nodes: ReadonlySignal<readonly SidebarNavNode[]>;
|
|
163
|
-
|
|
164
|
-
|
|
371
|
+
context: TreeContext;
|
|
372
|
+
root: boolean;
|
|
165
373
|
}) {
|
|
374
|
+
// Rows without a link or children render nothing, so first/last (which crop
|
|
375
|
+
// the rails) are taken from the rows that are actually drawn.
|
|
376
|
+
const visible = computed(() =>
|
|
377
|
+
nodes.value.filter((node) => node.children.length > 0 || Boolean(node.href)),
|
|
378
|
+
);
|
|
166
379
|
return (
|
|
167
|
-
<
|
|
168
|
-
{(node
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
>
|
|
177
|
-
{() => (
|
|
178
|
-
<CategoryNode node={node} depth={depth} isLast={isLast} initiallyCollapsedCategorySlugs={initiallyCollapsedCategorySlugs} />
|
|
179
|
-
)}
|
|
180
|
-
</Show>
|
|
181
|
-
);
|
|
182
|
-
}}
|
|
183
|
-
</For>
|
|
380
|
+
<ul class="zd-site-tree-list" role="list">
|
|
381
|
+
<For each={visible} by={(node) => node.slug}>
|
|
382
|
+
{(node, index) => {
|
|
383
|
+
const isLast = computed(() => index.value === visible.value.length - 1);
|
|
384
|
+
const isFirst = computed(() => index.value === 0);
|
|
385
|
+
return <TreeRow node={node} isFirst={isFirst} isLast={isLast} root={root} context={context} />;
|
|
386
|
+
}}
|
|
387
|
+
</For>
|
|
388
|
+
</ul>
|
|
184
389
|
);
|
|
185
390
|
}
|
|
186
391
|
|
|
187
|
-
function
|
|
392
|
+
function TreeRow({
|
|
188
393
|
node,
|
|
189
|
-
|
|
394
|
+
isFirst,
|
|
190
395
|
isLast,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
dateFormats,
|
|
194
|
-
updatedLabel = "Updated",
|
|
396
|
+
root,
|
|
397
|
+
context,
|
|
195
398
|
}: {
|
|
196
399
|
node: ReadonlySignal<SidebarNavNode>;
|
|
197
|
-
|
|
400
|
+
isFirst: ReadonlySignal<boolean>;
|
|
198
401
|
isLast: ReadonlySignal<boolean>;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
dateFormats?: ResolvedDateFormats;
|
|
202
|
-
updatedLabel?: string;
|
|
402
|
+
root: boolean;
|
|
403
|
+
context: TreeContext;
|
|
203
404
|
}) {
|
|
204
|
-
const
|
|
405
|
+
const group = node.value.children.length > 0;
|
|
406
|
+
const open = signal(
|
|
407
|
+
initialCategoryOpenState(context.initiallyCollapsed.has(node.value.slug)),
|
|
408
|
+
);
|
|
205
409
|
const toggle = () => {
|
|
206
410
|
open.value = toggleCategoryOpenState(open.value);
|
|
207
411
|
};
|
|
208
412
|
const label = computed(() => node.value.label);
|
|
209
413
|
const href = computed(() => node.value.href);
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
414
|
+
const description = computed(() =>
|
|
415
|
+
context.described ? (node.value.description ?? "") : "",
|
|
416
|
+
);
|
|
417
|
+
const controls = `${context.idPrefix}-${slugToId(node.value.slug)}`;
|
|
418
|
+
const labelClass = `zd-site-tree-label block min-w-0 flex-1 text-left text-fg break-words hover:text-accent hover:underline focus:underline focus-visible:text-accent${group ? " font-semibold" : ""}`;
|
|
419
|
+
const labelContent = (
|
|
420
|
+
<>
|
|
421
|
+
<span class="block">{label}</span>
|
|
422
|
+
<Show when={computed(() => description.value.length > 0)}>
|
|
216
423
|
{() => (
|
|
217
|
-
<
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
left: connectorLeft(depth),
|
|
221
|
-
top: "0px",
|
|
222
|
-
bottom: "0px",
|
|
223
|
-
}}
|
|
224
|
-
/>
|
|
424
|
+
<span class="mt-vsp-3xs block text-caption text-muted" data-site-tree-description>
|
|
425
|
+
{description}
|
|
426
|
+
</span>
|
|
225
427
|
)}
|
|
226
428
|
</Show>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
429
|
+
</>
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
return (
|
|
433
|
+
<li
|
|
434
|
+
class="zd-site-tree-row"
|
|
435
|
+
data-node={node.value.slug}
|
|
436
|
+
{...(group ? { "data-group": "" } : {})}
|
|
437
|
+
>
|
|
438
|
+
<span
|
|
439
|
+
aria-hidden="true"
|
|
440
|
+
class="zd-site-tree-rail"
|
|
441
|
+
data-tree-rail
|
|
442
|
+
{...(root ? { "data-root": "" } : {})}
|
|
443
|
+
data-first={computed(() => (isFirst.value ? "true" : "false"))}
|
|
444
|
+
data-last={computed(() => (isLast.value ? "true" : "false"))}
|
|
445
|
+
/>
|
|
446
|
+
<span aria-hidden="true" class="zd-site-tree-branch" data-tree-branch />
|
|
447
|
+
<div class="zd-site-tree-line relative flex min-w-0 items-start gap-hsp-xs">
|
|
448
|
+
{group && (
|
|
449
|
+
<DisclosureButton open={open} label={label} controls={controls} onToggle={toggle} />
|
|
450
|
+
)}
|
|
451
|
+
<Show
|
|
452
|
+
when={computed(() => Boolean(href.value))}
|
|
453
|
+
fallback={() => (
|
|
454
|
+
<button
|
|
455
|
+
type="button"
|
|
456
|
+
on:click={toggle}
|
|
457
|
+
class={labelClass}
|
|
458
|
+
aria-expanded={computed(() => (open.value ? "true" : "false"))}
|
|
459
|
+
aria-controls={controls}
|
|
460
|
+
>
|
|
461
|
+
{labelContent}
|
|
462
|
+
</button>
|
|
236
463
|
)}
|
|
237
|
-
|
|
238
|
-
<Show when={computed(() => !isLast.value)}>
|
|
464
|
+
>
|
|
239
465
|
{() => (
|
|
240
|
-
<
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
widthScale={CONNECTOR_WIDTH_SCALE}
|
|
244
|
-
topPad="calc(0.15rem + var(--spacing-vsp-xs))"
|
|
245
|
-
/>
|
|
466
|
+
<a href={computed(() => href.value ?? "")} class={labelClass}>
|
|
467
|
+
{labelContent}
|
|
468
|
+
</a>
|
|
246
469
|
)}
|
|
247
470
|
</Show>
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
on:click={toggle}
|
|
258
|
-
class="flex-1 min-w-0 break-words py-vsp-xs text-left hover:text-accent hover:underline focus:underline"
|
|
259
|
-
>
|
|
260
|
-
{label}
|
|
261
|
-
</button>
|
|
262
|
-
)}
|
|
263
|
-
>
|
|
471
|
+
{group && (
|
|
472
|
+
<Show when={open}>
|
|
473
|
+
{() => <span aria-hidden="true" class="zd-site-tree-stem" data-tree-stem />}
|
|
474
|
+
</Show>
|
|
475
|
+
)}
|
|
476
|
+
</div>
|
|
477
|
+
{group && (
|
|
478
|
+
<div id={controls} hidden={computed(() => !open.value)}>
|
|
479
|
+
<Show when={open}>
|
|
264
480
|
{() => (
|
|
265
|
-
<
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
<span class="flex h-[1lh] items-center">
|
|
271
|
-
<CategoryLinkIcon class="w-[18px]" />
|
|
272
|
-
</span>
|
|
273
|
-
)}
|
|
274
|
-
{label}
|
|
275
|
-
</a>
|
|
481
|
+
<NodeList
|
|
482
|
+
nodes={computed(() => node.value.children)}
|
|
483
|
+
context={context}
|
|
484
|
+
root={false}
|
|
485
|
+
/>
|
|
276
486
|
)}
|
|
277
487
|
</Show>
|
|
278
|
-
<button
|
|
279
|
-
type="button"
|
|
280
|
-
on:click={toggle}
|
|
281
|
-
class="aspect-square flex items-center justify-center w-[1.75rem] border-y border-l border-muted hover:underline focus:underline"
|
|
282
|
-
aria-expanded={computed(() => (open.value ? "true" : "false"))}
|
|
283
|
-
aria-label={computed(
|
|
284
|
-
() => `${open.value ? "Collapse" : "Expand"} ${label.value}`,
|
|
285
|
-
)}
|
|
286
|
-
>
|
|
287
|
-
<span
|
|
288
|
-
class="inline-flex transition-transform duration-150"
|
|
289
|
-
style={computed(
|
|
290
|
-
() => `transform:rotate(${open.value ? "90deg" : "0deg"})`,
|
|
291
|
-
)}
|
|
292
|
-
>
|
|
293
|
-
<ChevronRight class="h-icon-xs w-icon-xs text-muted" />
|
|
294
|
-
</span>
|
|
295
|
-
</button>
|
|
296
488
|
</div>
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
{() => (
|
|
300
|
-
<div>
|
|
301
|
-
<Show
|
|
302
|
-
when={computed(
|
|
303
|
-
() => node.value.shape === "note-tray" && depth === 0,
|
|
304
|
-
)}
|
|
305
|
-
fallback={() => (
|
|
306
|
-
<NodeList nodes={children} depth={depth + 1} initiallyCollapsedCategorySlugs={initiallyCollapsedCategorySlugs} />
|
|
307
|
-
)}
|
|
308
|
-
>
|
|
309
|
-
{() => (
|
|
310
|
-
<NoteTrayNodeList
|
|
311
|
-
node={node}
|
|
312
|
-
locale={locale}
|
|
313
|
-
dateFormats={dateFormats}
|
|
314
|
-
updatedLabel={updatedLabel}
|
|
315
|
-
/>
|
|
316
|
-
)}
|
|
317
|
-
</Show>
|
|
318
|
-
</div>
|
|
319
|
-
)}
|
|
320
|
-
</Show>
|
|
321
|
-
</div>
|
|
489
|
+
)}
|
|
490
|
+
</li>
|
|
322
491
|
);
|
|
323
492
|
}
|
|
324
493
|
|
|
@@ -473,69 +642,3 @@ function NoteTrayRow({
|
|
|
473
642
|
</Show>
|
|
474
643
|
);
|
|
475
644
|
}
|
|
476
|
-
|
|
477
|
-
function LeafNode({
|
|
478
|
-
node,
|
|
479
|
-
depth,
|
|
480
|
-
isLast,
|
|
481
|
-
}: {
|
|
482
|
-
node: ReadonlySignal<SidebarNavNode>;
|
|
483
|
-
depth: number;
|
|
484
|
-
isLast: ReadonlySignal<boolean>;
|
|
485
|
-
}) {
|
|
486
|
-
const href = computed(() => node.value.href);
|
|
487
|
-
const label = computed(() => node.value.label);
|
|
488
|
-
const isRoot = depth === 0;
|
|
489
|
-
const paddingLeft = padLeft(depth);
|
|
490
|
-
|
|
491
|
-
const topPad = isRoot
|
|
492
|
-
? "calc(var(--spacing-vsp-xs) + 0.15rem)"
|
|
493
|
-
: "var(--spacing-vsp-2xs)";
|
|
494
|
-
|
|
495
|
-
return (
|
|
496
|
-
<Show when={computed(() => Boolean(href.value))}>
|
|
497
|
-
{() => (
|
|
498
|
-
<div>
|
|
499
|
-
<div class="relative">
|
|
500
|
-
<Show when={isLast}>
|
|
501
|
-
{() => (
|
|
502
|
-
<ConnectorLines
|
|
503
|
-
depth={depth}
|
|
504
|
-
isLast={true}
|
|
505
|
-
widthScale={CONNECTOR_WIDTH_SCALE}
|
|
506
|
-
topPad={topPad}
|
|
507
|
-
/>
|
|
508
|
-
)}
|
|
509
|
-
</Show>
|
|
510
|
-
<Show when={computed(() => !isLast.value)}>
|
|
511
|
-
{() => (
|
|
512
|
-
<ConnectorLines
|
|
513
|
-
depth={depth}
|
|
514
|
-
isLast={false}
|
|
515
|
-
widthScale={CONNECTOR_WIDTH_SCALE}
|
|
516
|
-
topPad={topPad}
|
|
517
|
-
/>
|
|
518
|
-
)}
|
|
519
|
-
</Show>
|
|
520
|
-
<a
|
|
521
|
-
href={computed(() => href.value ?? "")}
|
|
522
|
-
class={computed(() =>
|
|
523
|
-
isRoot
|
|
524
|
-
? "flex items-start gap-hsp-xs py-[calc(var(--spacing-vsp-xs)_+_0.15rem)] pr-hsp-sm text-small font-semibold text-fg break-words hover:text-accent hover:underline focus:underline focus-visible:text-accent"
|
|
525
|
-
: `block py-vsp-2xs pr-hsp-sm ${isLast.value ? "pb-vsp-xs" : ""} text-small text-fg break-words hover:text-accent hover:underline focus:underline focus-visible:text-accent`,
|
|
526
|
-
)}
|
|
527
|
-
style={{ "padding-left": paddingLeft }}
|
|
528
|
-
>
|
|
529
|
-
{isRoot && (
|
|
530
|
-
<span class="flex h-[1lh] items-center">
|
|
531
|
-
<CategoryLinkIcon class="w-[18px]" />
|
|
532
|
-
</span>
|
|
533
|
-
)}
|
|
534
|
-
{isRoot ? <span class="min-w-0">{label}</span> : label}
|
|
535
|
-
</a>
|
|
536
|
-
</div>
|
|
537
|
-
</div>
|
|
538
|
-
)}
|
|
539
|
-
</Show>
|
|
540
|
-
);
|
|
541
|
-
}
|