@takazudo/zudo-doc 12.0.1 → 13.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 +12 -0
- package/dist/category-list/index.d.ts +68 -0
- package/dist/category-list/index.js +130 -0
- package/dist/category-list/model.d.ts +142 -0
- package/dist/category-list/model.js +174 -0
- package/dist/category-list/view.d.ts +56 -0
- package/dist/category-list/view.js +192 -0
- package/dist/chrome/derive.d.ts +7 -0
- package/dist/chrome/derive.js +25 -0
- package/dist/compiled.css +202 -0
- package/dist/config-assertions/index.d.ts +2 -2
- package/dist/config-assertions/index.js +16 -7
- package/dist/features.css +213 -0
- package/dist/home-page/index.js +37 -3
- package/dist/i18n-defaults/index.js +6 -0
- package/dist/mdx-components/vocabulary.d.ts +1 -1
- package/dist/mdx-components/vocabulary.js +2 -1
- package/dist/plugins/internal/agent-export/components.js +47 -0
- package/dist/settings.d.ts +25 -3
- package/package.json +14 -10
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
2
|
+
import { formatDate, formatMonthDayLabel, formatYear } from "../format-date/index.js";
|
|
3
|
+
import { CategoryLinkIcon } from "../tree-nav-shared/index.js";
|
|
4
|
+
import {
|
|
5
|
+
resolveCategoryListLead
|
|
6
|
+
} from "./model.js";
|
|
7
|
+
function resolveCategoryListDisplay(options) {
|
|
8
|
+
return {
|
|
9
|
+
layout: options.layout ?? "cards",
|
|
10
|
+
lead: options.lead ?? "auto",
|
|
11
|
+
showDescription: options.showDescription ?? true,
|
|
12
|
+
showDate: options.showDate ?? false,
|
|
13
|
+
showUpdated: options.showUpdated ?? false,
|
|
14
|
+
showTags: options.showTags ?? false,
|
|
15
|
+
showPath: options.showPath ?? false,
|
|
16
|
+
showCount: options.showCount ?? false,
|
|
17
|
+
showArchive: options.showArchive ?? true
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function fillCount(template, shown, total) {
|
|
21
|
+
return template.replace(/\{shown\}/g, String(shown)).replace(/\{total\}/g, String(total));
|
|
22
|
+
}
|
|
23
|
+
const LINKED_MUTED = "text-muted group-hover:text-accent group-focus-visible:text-accent";
|
|
24
|
+
function Lead({
|
|
25
|
+
item,
|
|
26
|
+
kind,
|
|
27
|
+
layout,
|
|
28
|
+
width,
|
|
29
|
+
locale,
|
|
30
|
+
dateFormats
|
|
31
|
+
}) {
|
|
32
|
+
if (kind === "rank") {
|
|
33
|
+
if (item.rank === void 0) return /* @__PURE__ */ jsx("span", { class: "zd-category-list-lead" });
|
|
34
|
+
return /* @__PURE__ */ jsx("span", { class: `zd-category-list-lead zd-category-list-rank tabular-nums ${LINKED_MUTED}`, children: String(item.rank).padStart(width, "0") });
|
|
35
|
+
}
|
|
36
|
+
if (!item.date) return /* @__PURE__ */ jsx("span", { class: "zd-category-list-lead" });
|
|
37
|
+
if (layout === "list") {
|
|
38
|
+
return /* @__PURE__ */ jsxs("time", { datetime: item.date, class: `zd-category-list-lead tabular-nums ${LINKED_MUTED}`, children: [
|
|
39
|
+
/* @__PURE__ */ jsx("span", { class: "block text-small font-medium leading-tight", children: formatMonthDayLabel(item.date, locale, dateFormats?.monthDay) }),
|
|
40
|
+
" ",
|
|
41
|
+
/* @__PURE__ */ jsx("span", { class: "block text-micro", children: formatYear(item.date, locale, dateFormats?.year) })
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsx("time", { datetime: item.date, class: `zd-category-list-lead tabular-nums text-caption ${LINKED_MUTED}`, children: formatDate(item.date, locale, dateFormats?.full) });
|
|
45
|
+
}
|
|
46
|
+
function Meta({
|
|
47
|
+
item,
|
|
48
|
+
display,
|
|
49
|
+
leadKind,
|
|
50
|
+
labels,
|
|
51
|
+
locale,
|
|
52
|
+
dateFormats
|
|
53
|
+
}) {
|
|
54
|
+
const parts = [];
|
|
55
|
+
if (display.showDate && item.date && leadKind !== "date") {
|
|
56
|
+
parts.push(
|
|
57
|
+
/* @__PURE__ */ jsx("time", { datetime: item.date, class: "tabular-nums", children: formatDate(item.date, locale, dateFormats?.full) }, "date")
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (display.showUpdated && item.updated && item.updated !== item.date) {
|
|
61
|
+
parts.push(
|
|
62
|
+
/* @__PURE__ */ jsxs("span", { class: "tabular-nums", children: [
|
|
63
|
+
labels.updated,
|
|
64
|
+
" ",
|
|
65
|
+
/* @__PURE__ */ jsx("time", { datetime: item.updated, children: formatDate(item.updated, locale, dateFormats?.full) })
|
|
66
|
+
] }, "updated")
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (display.showPath && item.path.length > 0) {
|
|
70
|
+
parts.push(
|
|
71
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
72
|
+
/* @__PURE__ */ jsxs("span", { class: "sr-only", children: [
|
|
73
|
+
labels.path,
|
|
74
|
+
" "
|
|
75
|
+
] }),
|
|
76
|
+
item.path.join(" / ")
|
|
77
|
+
] }, "path")
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
if (display.showTags && item.tags.length > 0) {
|
|
81
|
+
parts.push(
|
|
82
|
+
/* @__PURE__ */ jsxs("span", { class: "zd-category-list-tags", children: [
|
|
83
|
+
/* @__PURE__ */ jsxs("span", { class: "sr-only", children: [
|
|
84
|
+
labels.tags,
|
|
85
|
+
": "
|
|
86
|
+
] }),
|
|
87
|
+
item.tags.map((tag) => /* @__PURE__ */ jsx("span", { class: "zd-category-list-tag rounded border border-muted px-hsp-2xs", children: tag }, tag))
|
|
88
|
+
] }, "tags")
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (parts.length === 0) return null;
|
|
92
|
+
return /* @__PURE__ */ jsx("span", { class: `zd-category-list-meta text-caption ${LINKED_MUTED}`, children: parts });
|
|
93
|
+
}
|
|
94
|
+
function Title({ level, children }) {
|
|
95
|
+
const className = "zd-category-list-title font-medium leading-snug text-fg group-hover:text-accent group-hover:underline group-focus-visible:text-accent group-focus-visible:underline";
|
|
96
|
+
return level === 4 ? /* @__PURE__ */ jsx("h4", { class: className, children }) : /* @__PURE__ */ jsx("h3", { class: className, children });
|
|
97
|
+
}
|
|
98
|
+
function CategoryListView({
|
|
99
|
+
resolved,
|
|
100
|
+
display,
|
|
101
|
+
labels,
|
|
102
|
+
locale,
|
|
103
|
+
dateFormats,
|
|
104
|
+
titleLevel = 3
|
|
105
|
+
}) {
|
|
106
|
+
const { items, total, category } = resolved;
|
|
107
|
+
if (items.length === 0) return null;
|
|
108
|
+
const leadKind = resolveCategoryListLead(display.lead, category);
|
|
109
|
+
const width = resolved.rankWidth ?? 2;
|
|
110
|
+
const hasLead = leadKind === "rank" ? items.some((item) => item.rank !== void 0) : leadKind === "date" ? items.some((item) => item.date !== void 0) : false;
|
|
111
|
+
const effectiveLead = hasLead ? leadKind : "none";
|
|
112
|
+
const archiveHref = display.showArchive ? category.href : void 0;
|
|
113
|
+
const showFooter = display.showCount || archiveHref !== void 0;
|
|
114
|
+
return /* @__PURE__ */ jsxs(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
class: "zd-category-list",
|
|
118
|
+
"data-zd-category-list": category.slug,
|
|
119
|
+
"data-layout": display.layout,
|
|
120
|
+
"data-lead": effectiveLead,
|
|
121
|
+
...display.showDescription ? { "data-descriptions": "" } : {},
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx("ul", { class: "zd-category-list-items", role: "list", children: items.map((item) => /* @__PURE__ */ jsx("li", { class: "zd-category-list-item", children: /* @__PURE__ */ jsxs(
|
|
124
|
+
"a",
|
|
125
|
+
{
|
|
126
|
+
href: item.href,
|
|
127
|
+
class: "zd-category-list-link group text-fg",
|
|
128
|
+
style: effectiveLead === "rank" ? { "--zd-category-list-rank-width": `${width}ch` } : void 0,
|
|
129
|
+
children: [
|
|
130
|
+
effectiveLead !== "none" && /* @__PURE__ */ jsx(
|
|
131
|
+
Lead,
|
|
132
|
+
{
|
|
133
|
+
item,
|
|
134
|
+
kind: effectiveLead,
|
|
135
|
+
layout: display.layout,
|
|
136
|
+
width,
|
|
137
|
+
locale,
|
|
138
|
+
dateFormats
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ jsxs("div", { class: "zd-category-list-body", children: [
|
|
142
|
+
/* @__PURE__ */ jsx(Title, { level: titleLevel, children: item.title }),
|
|
143
|
+
display.showDescription && item.description && /* @__PURE__ */ jsx("span", { class: `zd-category-list-description block text-small ${LINKED_MUTED}`, children: item.description }),
|
|
144
|
+
display.layout === "list" && /* @__PURE__ */ jsx(
|
|
145
|
+
Meta,
|
|
146
|
+
{
|
|
147
|
+
item,
|
|
148
|
+
display,
|
|
149
|
+
leadKind: effectiveLead,
|
|
150
|
+
labels,
|
|
151
|
+
locale,
|
|
152
|
+
dateFormats
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] }),
|
|
156
|
+
display.layout === "cards" && /* @__PURE__ */ jsx(
|
|
157
|
+
Meta,
|
|
158
|
+
{
|
|
159
|
+
item,
|
|
160
|
+
display,
|
|
161
|
+
leadKind: effectiveLead,
|
|
162
|
+
labels,
|
|
163
|
+
locale,
|
|
164
|
+
dateFormats
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ jsx(CategoryLinkIcon, { class: `zd-category-list-chevron w-icon-sm ${LINKED_MUTED}` })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
) }, item.slug)) }),
|
|
171
|
+
showFooter && /* @__PURE__ */ jsxs("div", { class: "zd-category-list-footer text-small", children: [
|
|
172
|
+
display.showCount && /* @__PURE__ */ jsx("p", { class: "zd-category-list-count text-caption text-muted tabular-nums", children: fillCount(labels.count, items.length, total) }),
|
|
173
|
+
archiveHref !== void 0 && /* @__PURE__ */ jsxs(
|
|
174
|
+
"a",
|
|
175
|
+
{
|
|
176
|
+
href: archiveHref,
|
|
177
|
+
class: "zd-category-list-archive group inline-flex items-center gap-hsp-xs text-fg hover:text-accent hover:underline focus-visible:text-accent focus-visible:underline",
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsx("span", { children: labels.archive }),
|
|
180
|
+
/* @__PURE__ */ jsx(CategoryLinkIcon, { class: "w-icon-sm text-muted group-hover:text-accent group-focus-visible:text-accent" })
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
] })
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
export {
|
|
190
|
+
CategoryListView,
|
|
191
|
+
resolveCategoryListDisplay
|
|
192
|
+
};
|
package/dist/chrome/derive.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
|
4
4
|
import type { ChromeContext, FactoryComponent } from "../factory-context/index.js";
|
|
5
5
|
import type { ResolvedDateFormats, Settings } from "../settings.js";
|
|
6
6
|
import { type ColorScheme } from "../color-scheme-utils.js";
|
|
7
|
+
import { type CategoryListDeps } from "../category-list/index.js";
|
|
7
8
|
export { normalizeIslandData } from "./island-data.js";
|
|
8
9
|
/** Package-default color scheme used when `colorSchemes` is `null` or a key is
|
|
9
10
|
* missing. Exported so `createChrome` keeps the identical fallback. Base roles
|
|
@@ -164,6 +165,12 @@ export declare function deriveInlineVersionSwitcher(ctx: ChromeContext, getUnava
|
|
|
164
165
|
* and a host-supplied `ctx.components` override, since the prop injection
|
|
165
166
|
* happens one layer up in `createMdxComponents()`, after the wrapper choice.
|
|
166
167
|
*/
|
|
168
|
+
/**
|
|
169
|
+
* Category-list dependencies bound to a chrome context (#4802). Shared by the
|
|
170
|
+
* `<CategoryList>` MDX binding and the `category-list` home section so both
|
|
171
|
+
* resolve through the same nav source, tag vocabulary and date formats.
|
|
172
|
+
*/
|
|
173
|
+
export declare function deriveCategoryListDeps(ctx: ChromeContext): CategoryListDeps;
|
|
167
174
|
export declare function deriveMdxComponents(ctx: ChromeContext): {
|
|
168
175
|
createMdxComponentsBound: (lang?: string, currentVersion?: string, currentSlug?: string) => Record<string, unknown>;
|
|
169
176
|
SiteTreeNavWrapper: FactoryComponent;
|
package/dist/chrome/derive.js
CHANGED
|
@@ -20,6 +20,9 @@ import { createNoteTrayIndexWrapper } from "../note-tray-index/index.js";
|
|
|
20
20
|
import { createCategoryTreeNavWrapper } from "../category-tree-nav/index.js";
|
|
21
21
|
import { createSiteTreeNavWrapper } from "../site-tree-nav/index.js";
|
|
22
22
|
import { createDocCardNavWrapper } from "../doc-card-nav/index.js";
|
|
23
|
+
import {
|
|
24
|
+
createCategoryListWrapper
|
|
25
|
+
} from "../category-list/index.js";
|
|
23
26
|
import { WideSectionHeading } from "../content/wide-section-heading.js";
|
|
24
27
|
import { Details } from "../details/index.js";
|
|
25
28
|
import {
|
|
@@ -283,6 +286,24 @@ function deriveInlineVersionSwitcher(ctx, getUnavailableVersions = deriveGetUnav
|
|
|
283
286
|
getUnavailableVersions
|
|
284
287
|
});
|
|
285
288
|
}
|
|
289
|
+
function deriveCategoryListDeps(ctx) {
|
|
290
|
+
return {
|
|
291
|
+
defaultLocale: ctx.defaultLocale,
|
|
292
|
+
docTags: ctx.settings.docTags,
|
|
293
|
+
resolveNavSource: ctx.resolveNavSource,
|
|
294
|
+
buildNavTree: ((docs, locale, categoryMeta) => ctx.buildNavTree(
|
|
295
|
+
docs,
|
|
296
|
+
locale,
|
|
297
|
+
categoryMeta,
|
|
298
|
+
(slug, loc) => ctx.docsUrl(slug, loc)
|
|
299
|
+
)),
|
|
300
|
+
toRouteSlug: ctx.toRouteSlug,
|
|
301
|
+
resolveTag: (raw) => ctx.resolveTagBound(raw).canonical,
|
|
302
|
+
t: (key, locale) => ctx.t(key, locale),
|
|
303
|
+
versionedDocsUrl: ctx.versionedDocsUrl,
|
|
304
|
+
dateFormat: ctx.settings.dateFormat
|
|
305
|
+
};
|
|
306
|
+
}
|
|
286
307
|
function deriveMdxComponents(ctx) {
|
|
287
308
|
const CategoryNavWrapper = ctx.components.CategoryNav ?? createCategoryNavWrapper({
|
|
288
309
|
defaultLocale: ctx.defaultLocale,
|
|
@@ -354,6 +375,7 @@ function deriveMdxComponents(ctx) {
|
|
|
354
375
|
docsUrl: (slug, locale) => ctx.docsUrl(slug, locale),
|
|
355
376
|
versionedDocsUrl: ctx.versionedDocsUrl
|
|
356
377
|
});
|
|
378
|
+
const CategoryListWrapper = createCategoryListWrapper(deriveCategoryListDeps(ctx));
|
|
357
379
|
const assetComponentContext = {
|
|
358
380
|
base: ctx.settings.base,
|
|
359
381
|
assetManifest: ctx.assetManifest,
|
|
@@ -401,6 +423,8 @@ function deriveMdxComponents(ctx) {
|
|
|
401
423
|
Details,
|
|
402
424
|
// Selected-document cards resolve against this page's locale/version.
|
|
403
425
|
DocCardNav: ((props) => DocCardNavWrapper({ ...props, lang, currentVersion })),
|
|
426
|
+
// Category listings resolve against this page's locale/version (#4802).
|
|
427
|
+
CategoryList: ((props) => CategoryListWrapper({ ...props, lang, currentVersion })),
|
|
404
428
|
WideSectionHeading,
|
|
405
429
|
HtmlPreview: HtmlPreviewBound,
|
|
406
430
|
Island: IslandPassthrough,
|
|
@@ -437,6 +461,7 @@ function deriveMdxComponents(ctx) {
|
|
|
437
461
|
export {
|
|
438
462
|
DEFAULT_SCHEME,
|
|
439
463
|
deriveBodyEndIslands,
|
|
464
|
+
deriveCategoryListDeps,
|
|
440
465
|
deriveColorSchemeGenerators,
|
|
441
466
|
deriveComposeMetaTitle,
|
|
442
467
|
deriveDateFormats,
|
package/dist/compiled.css
CHANGED
|
@@ -2347,6 +2347,208 @@ html[data-theme="dark"] [data-zd-home-image="light"], html:not([data-theme="dark
|
|
|
2347
2347
|
border-color: canvastext;
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
2350
|
+
|
|
2351
|
+
.zd-category-list {
|
|
2352
|
+
container: zd-category-list / inline-size;
|
|
2353
|
+
min-width: 0;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
.zd-category-list-items {
|
|
2357
|
+
display: grid;
|
|
2358
|
+
grid-template-columns: minmax(0, 1fr);
|
|
2359
|
+
margin: 0;
|
|
2360
|
+
padding: 0;
|
|
2361
|
+
list-style: none;
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
.zd-category-list-item {
|
|
2365
|
+
min-width: 0;
|
|
2366
|
+
margin: 0;
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
.zd-category-list-link {
|
|
2370
|
+
display: grid;
|
|
2371
|
+
min-width: 0;
|
|
2372
|
+
height: 100%;
|
|
2373
|
+
text-decoration: none;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
.zd-category-list-body {
|
|
2377
|
+
display: flex;
|
|
2378
|
+
min-width: 0;
|
|
2379
|
+
flex-direction: column;
|
|
2380
|
+
gap: var(--spacing-vsp-3xs);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
.zd-category-list-title, .zd-category-list-description, .zd-category-list-meta {
|
|
2384
|
+
min-width: 0;
|
|
2385
|
+
margin: 0;
|
|
2386
|
+
overflow-wrap: anywhere;
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
.zd-category-list-title {
|
|
2390
|
+
font-size: var(--text-body);
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
.zd-category-list-link:is(:hover, :focus-visible) .zd-category-list-title {
|
|
2394
|
+
color: var(--color-accent);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
.zd-category-list-meta {
|
|
2398
|
+
display: flex;
|
|
2399
|
+
flex-wrap: wrap;
|
|
2400
|
+
align-items: baseline;
|
|
2401
|
+
gap: var(--spacing-vsp-3xs) var(--spacing-hsp-md);
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
.zd-category-list-tags {
|
|
2405
|
+
display: inline-flex;
|
|
2406
|
+
flex-wrap: wrap;
|
|
2407
|
+
gap: var(--spacing-hsp-xs);
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
.zd-category-list-tag {
|
|
2411
|
+
font-size: var(--text-micro);
|
|
2412
|
+
line-height: var(--leading-normal);
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
.zd-category-list-rank {
|
|
2416
|
+
min-width: var(--zd-category-list-rank-width, 2ch);
|
|
2417
|
+
font-size: var(--text-title);
|
|
2418
|
+
line-height: var(--leading-tight);
|
|
2419
|
+
white-space: nowrap;
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
.zd-category-list-chevron {
|
|
2423
|
+
font-size: var(--text-body);
|
|
2424
|
+
line-height: var(--leading-snug);
|
|
2425
|
+
align-self: start;
|
|
2426
|
+
margin-block-start: calc((1lh - var(--spacing-icon-sm)) / 2);
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
.zd-category-list-footer {
|
|
2430
|
+
display: flex;
|
|
2431
|
+
flex-wrap: wrap;
|
|
2432
|
+
align-items: center;
|
|
2433
|
+
justify-content: space-between;
|
|
2434
|
+
gap: var(--spacing-vsp-2xs) var(--spacing-hsp-lg);
|
|
2435
|
+
margin-top: var(--spacing-vsp-sm);
|
|
2436
|
+
padding-top: var(--spacing-vsp-xs);
|
|
2437
|
+
border-top: 1px solid var(--color-muted);
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
.zd-category-list-count {
|
|
2441
|
+
margin: 0;
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
.zd-category-list-archive {
|
|
2445
|
+
margin-inline-start: auto;
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-items {
|
|
2449
|
+
gap: var(--spacing-vsp-sm) var(--spacing-hsp-lg);
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-link {
|
|
2453
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
2454
|
+
grid-template-areas: "body chevron"
|
|
2455
|
+
"meta meta";
|
|
2456
|
+
grid-template-rows: auto 1fr;
|
|
2457
|
+
column-gap: var(--spacing-hsp-md);
|
|
2458
|
+
row-gap: var(--spacing-vsp-xs);
|
|
2459
|
+
padding: var(--spacing-vsp-sm) var(--spacing-hsp-xl);
|
|
2460
|
+
border: 1px solid var(--color-muted);
|
|
2461
|
+
border-radius: var(--radius-DEFAULT);
|
|
2462
|
+
background: var(--color-surface);
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
.zd-category-list[data-layout="cards"]:not([data-lead="none"]) .zd-category-list-link {
|
|
2466
|
+
grid-template-areas: "lead chevron"
|
|
2467
|
+
"body body"
|
|
2468
|
+
"meta meta";
|
|
2469
|
+
grid-template-rows: auto auto 1fr;
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-lead {
|
|
2473
|
+
grid-area: lead;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-body {
|
|
2477
|
+
grid-area: body;
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-chevron {
|
|
2481
|
+
grid-area: chevron;
|
|
2482
|
+
justify-self: end;
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
.zd-category-list[data-layout="cards"]:not([data-lead="none"]) .zd-category-list-chevron {
|
|
2486
|
+
align-self: center;
|
|
2487
|
+
margin-block-start: 0;
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-meta {
|
|
2491
|
+
grid-area: meta;
|
|
2492
|
+
align-self: end;
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-link:is(:hover, :focus-visible) {
|
|
2496
|
+
border-color: var(--color-accent);
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
@container zd-category-list (width >= 36rem) {
|
|
2500
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-items {
|
|
2501
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
@container zd-category-list (width >= 64rem) {
|
|
2506
|
+
.zd-category-list[data-layout="cards"] .zd-category-list-items {
|
|
2507
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
.zd-category-list[data-layout="list"] .zd-category-list-items {
|
|
2512
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
2513
|
+
column-gap: var(--spacing-hsp-2xl);
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
.zd-category-list[data-layout="list"] .zd-category-list-item {
|
|
2517
|
+
border-bottom: 1px solid var(--color-muted);
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
.zd-category-list[data-layout="list"] .zd-category-list-link {
|
|
2521
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
2522
|
+
column-gap: var(--spacing-hsp-md);
|
|
2523
|
+
align-items: start;
|
|
2524
|
+
padding: var(--spacing-vsp-xs) var(--spacing-hsp-2xs);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
.zd-category-list[data-layout="list"][data-lead="rank"] .zd-category-list-link {
|
|
2528
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
.zd-category-list[data-layout="list"][data-lead="date"] .zd-category-list-link {
|
|
2532
|
+
grid-template-columns: 4.5rem minmax(0, 1fr) auto;
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
.zd-category-list[data-layout="list"] .zd-category-list-link:is(:hover, :focus-visible) {
|
|
2536
|
+
background: color-mix(in oklch, var(--color-surface) 70%, transparent);
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
.zd-category-list[data-layout="list"] .zd-category-list-meta {
|
|
2540
|
+
margin-top: var(--spacing-vsp-3xs);
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
.zd-category-list[data-layout="list"] .zd-category-list-footer {
|
|
2544
|
+
border-top: 0;
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
@container zd-category-list (width <= 520px) {
|
|
2548
|
+
.zd-category-list[data-layout="list"] .zd-category-list-items {
|
|
2549
|
+
grid-template-columns: minmax(0, 1fr);
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2350
2552
|
.block {
|
|
2351
2553
|
display: block;
|
|
2352
2554
|
}
|
|
@@ -111,8 +111,8 @@ export interface LocaleOgImageSubject {
|
|
|
111
111
|
export declare function assertValidLocaleOgImages(settings: LocaleOgImageSubject): void;
|
|
112
112
|
/**
|
|
113
113
|
* Validate `home.sections`: absent, or an array holding exactly one
|
|
114
|
-
* `{ type: "site-tree" }
|
|
115
|
-
*
|
|
114
|
+
* `{ type: "site-tree" }`, at most one `{ type: "doc-cards", docs }` and any
|
|
115
|
+
* number of `{ type: "category-list", category, limit }`, in any order. Every field is serializable presentation data — unknown
|
|
116
116
|
* kinds, unknown keys, non-string text, invalid variants and non-canonical
|
|
117
117
|
* slugs (leading/trailing `/`, whitespace, URLs) throw a `TypeError` naming
|
|
118
118
|
* the entry. Whether a slug matches a published document is checked at
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CONTROL_CHARS } from "../asset-path/index.js";
|
|
2
2
|
import { CONTENT_SIGNAL_KEYS } from "../robots.js";
|
|
3
3
|
import { isCanonicalDocSlug } from "../doc-card-nav/slug.js";
|
|
4
|
+
import { assertValidCategoryListOptions, CATEGORY_LIST_OPTION_KEYS } from "../category-list/model.js";
|
|
4
5
|
function assertAgentDocsConsistent(settings) {
|
|
5
6
|
if (settings.agentExport !== void 0 && typeof settings.agentExport !== "boolean") {
|
|
6
7
|
throw new TypeError("agentExport must be a boolean.");
|
|
@@ -146,9 +147,14 @@ function assertValidLocaleOgImages(settings) {
|
|
|
146
147
|
}
|
|
147
148
|
const HOME_SECTION_KEYS = {
|
|
148
149
|
"doc-cards": /* @__PURE__ */ new Set(["type", "heading", "description", "docs", "locales"]),
|
|
149
|
-
"site-tree": /* @__PURE__ */ new Set(["type", "heading", "description", "variant", "locales"])
|
|
150
|
+
"site-tree": /* @__PURE__ */ new Set(["type", "heading", "description", "variant", "locales"]),
|
|
151
|
+
"category-list": /* @__PURE__ */ new Set(["type", "heading", "description", "locales", ...CATEGORY_LIST_OPTION_KEYS])
|
|
152
|
+
};
|
|
153
|
+
const HOME_SECTION_LOCALE_KEYS = {
|
|
154
|
+
"doc-cards": /* @__PURE__ */ new Set(["heading", "description"]),
|
|
155
|
+
"site-tree": /* @__PURE__ */ new Set(["heading", "description"]),
|
|
156
|
+
"category-list": /* @__PURE__ */ new Set(["heading", "description", "archiveLabel"])
|
|
150
157
|
};
|
|
151
|
-
const HOME_SECTION_LOCALE_KEYS = /* @__PURE__ */ new Set(["heading", "description"]);
|
|
152
158
|
function isPlainRecord(value) {
|
|
153
159
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
154
160
|
}
|
|
@@ -163,16 +169,16 @@ function assertValidHomeSections(settings) {
|
|
|
163
169
|
);
|
|
164
170
|
}
|
|
165
171
|
const knownLocales = typeof settings.defaultLocale === "string" ? /* @__PURE__ */ new Set([settings.defaultLocale, ...isPlainRecord(settings.locales) ? Object.keys(settings.locales) : []]) : void 0;
|
|
166
|
-
const counts = { "doc-cards": 0, "site-tree": 0 };
|
|
172
|
+
const counts = { "doc-cards": 0, "site-tree": 0, "category-list": 0 };
|
|
167
173
|
value.forEach((entry, index) => {
|
|
168
174
|
const at = `home.sections[${index}]`;
|
|
169
175
|
if (!isPlainRecord(entry)) {
|
|
170
176
|
throw new TypeError(`Invalid ${at} ${describeValue(entry)}: each section must be an object.`);
|
|
171
177
|
}
|
|
172
178
|
const type = entry.type;
|
|
173
|
-
if (type !== "doc-cards" && type !== "site-tree") {
|
|
179
|
+
if (type !== "doc-cards" && type !== "site-tree" && type !== "category-list") {
|
|
174
180
|
throw new TypeError(
|
|
175
|
-
`Invalid ${at}.type ${describeValue(type)}: allowed section types are "doc-cards"
|
|
181
|
+
`Invalid ${at}.type ${describeValue(type)}: allowed section types are "doc-cards", "site-tree" and "category-list".`
|
|
176
182
|
);
|
|
177
183
|
}
|
|
178
184
|
const allowed = HOME_SECTION_KEYS[type];
|
|
@@ -203,10 +209,11 @@ function assertValidHomeSections(settings) {
|
|
|
203
209
|
if (!isPlainRecord(text)) {
|
|
204
210
|
throw new TypeError(`Invalid ${at}.locales.${code} ${describeValue(text)}: must be an object.`);
|
|
205
211
|
}
|
|
212
|
+
const localeKeys = HOME_SECTION_LOCALE_KEYS[type];
|
|
206
213
|
for (const [key, v] of Object.entries(text)) {
|
|
207
|
-
if (!
|
|
214
|
+
if (!localeKeys.has(key)) {
|
|
208
215
|
throw new TypeError(
|
|
209
|
-
`Invalid ${at}.locales.${code}: unknown key "${key}". Allowed keys:
|
|
216
|
+
`Invalid ${at}.locales.${code}: unknown key "${key}". Allowed keys: ${[...localeKeys].join(", ")}.`
|
|
210
217
|
);
|
|
211
218
|
}
|
|
212
219
|
if (v !== void 0 && typeof v !== "string") {
|
|
@@ -229,6 +236,8 @@ function assertValidHomeSections(settings) {
|
|
|
229
236
|
);
|
|
230
237
|
}
|
|
231
238
|
});
|
|
239
|
+
} else if (type === "category-list") {
|
|
240
|
+
assertValidCategoryListOptions(entry, at, ["type", "heading", "description", "locales"]);
|
|
232
241
|
} else if (entry.variant !== void 0 && entry.variant !== "default" && entry.variant !== "described") {
|
|
233
242
|
throw new TypeError(
|
|
234
243
|
`Invalid ${at}.variant ${describeValue(entry.variant)}: must be "default" or "described".`
|