@dogsbay/docs-layout 0.2.0-beta.0 → 0.2.0-beta.10
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/package.json +3 -3
- package/src/DocsLayout.astro +32 -0
- package/src/TaxonomyTerm.astro +15 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dogsbay/docs-layout",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.10",
|
|
4
4
|
"description": "Standard documentation layout components for Dogsbay",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"./json-ld": "./src/json-ld.ts"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dogsbay/ui": "0.2.0-beta.
|
|
33
|
-
"@dogsbay/primitives": "0.2.0-beta.
|
|
32
|
+
"@dogsbay/ui": "0.2.0-beta.10",
|
|
33
|
+
"@dogsbay/primitives": "0.2.0-beta.10"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"vitest": "^3.0.0"
|
package/src/DocsLayout.astro
CHANGED
|
@@ -256,6 +256,23 @@ interface Props {
|
|
|
256
256
|
* elements in `<body>`.
|
|
257
257
|
*/
|
|
258
258
|
category?: string[];
|
|
259
|
+
/**
|
|
260
|
+
* Custom-taxonomy values from `meta.taxonomies` — anything declared
|
|
261
|
+
* in `taxonomies:` config that isn't one of the five hardcoded
|
|
262
|
+
* built-ins (`tags`, `category`, `audience`, `type`, `status`).
|
|
263
|
+
*
|
|
264
|
+
* Each entry becomes one `<div data-pagefind-filter="<name>:<value>">`
|
|
265
|
+
* inside the indexed body, so the search dialog grows a checkbox
|
|
266
|
+
* group for every custom taxonomy automatically. No extra config
|
|
267
|
+
* needed beyond declaring the taxonomy in `dogsbay.config.yml` —
|
|
268
|
+
* the search dialog discovers facets at index time and renders
|
|
269
|
+
* whatever Pagefind reports.
|
|
270
|
+
*
|
|
271
|
+
* Display labels for the checkboxes flow through
|
|
272
|
+
* `taxonomyDisplay[<name>]` (same prefix/label config that drives
|
|
273
|
+
* chip rendering elsewhere). When unset, raw slugs are shown.
|
|
274
|
+
*/
|
|
275
|
+
taxonomies?: Record<string, string[]>;
|
|
259
276
|
/**
|
|
260
277
|
* Map of taxonomy name → index path for declared taxonomies.
|
|
261
278
|
* Used to wire links from built-in field badges (TypeBadge,
|
|
@@ -398,6 +415,7 @@ const {
|
|
|
398
415
|
pageType,
|
|
399
416
|
audience,
|
|
400
417
|
category,
|
|
418
|
+
taxonomies,
|
|
401
419
|
taxonomyIndexPaths,
|
|
402
420
|
taxonomyDisplay,
|
|
403
421
|
autoH1,
|
|
@@ -720,6 +738,20 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
720
738
|
))}
|
|
721
739
|
{status && <div hidden data-pagefind-filter={`status:${status}`}></div>}
|
|
722
740
|
{pageType && <div hidden data-pagefind-filter={`type:${pageType}`}></div>}
|
|
741
|
+
{/*
|
|
742
|
+
Custom-taxonomy filters. Any taxonomy declared in
|
|
743
|
+
`dogsbay.config.yml` that isn't one of the five built-ins
|
|
744
|
+
flows through here, so `difficulty: intermediate` (etc.)
|
|
745
|
+
becomes a real Pagefind facet checkbox automatically.
|
|
746
|
+
See plans/beta-launch-followups.md for context.
|
|
747
|
+
*/}
|
|
748
|
+
{taxonomies && Object.entries(taxonomies).flatMap(([name, values]) =>
|
|
749
|
+
Array.isArray(values)
|
|
750
|
+
? values.map((value) => (
|
|
751
|
+
<div hidden data-pagefind-filter={`${name}:${value}`}></div>
|
|
752
|
+
))
|
|
753
|
+
: []
|
|
754
|
+
)}
|
|
723
755
|
|
|
724
756
|
<div class:list={["mx-auto", wideLayout ? "max-w-7xl" : "max-w-3xl"]}>
|
|
725
757
|
{/*
|
package/src/TaxonomyTerm.astro
CHANGED
|
@@ -93,15 +93,22 @@ function segmentLabel(depth: number): string {
|
|
|
93
93
|
|
|
94
94
|
const titleSegments = term.fullPath.map((_, i) => segmentLabel(i));
|
|
95
95
|
|
|
96
|
-
// Breadcrumb segments —
|
|
96
|
+
// Breadcrumb segments — only link to prefixes that have their own
|
|
97
|
+
// term page. When a taxonomy is non-hierarchical, only full-path
|
|
98
|
+
// terms exist in `data.terms`; linking to `/tags/<prefix>/` for an
|
|
99
|
+
// intermediate segment would 404. Render those as plain text instead.
|
|
97
100
|
function breadcrumbs() {
|
|
98
|
-
const
|
|
101
|
+
const termKeys = new Set(data.terms.map((t) => t.fullPath.join("/")));
|
|
102
|
+
const out: { label: string; href?: string }[] = [
|
|
99
103
|
{ label: displayName, href: `${data.indexPath}/` },
|
|
100
104
|
];
|
|
101
105
|
for (let i = 0; i < term.fullPath.length - 1; i++) {
|
|
106
|
+
const prefix = term.fullPath.slice(0, i + 1).join("/");
|
|
102
107
|
out.push({
|
|
103
108
|
label: segmentLabel(i),
|
|
104
|
-
href:
|
|
109
|
+
href: termKeys.has(prefix)
|
|
110
|
+
? `${data.indexPath}/${prefix}/`
|
|
111
|
+
: undefined,
|
|
105
112
|
});
|
|
106
113
|
}
|
|
107
114
|
return out;
|
|
@@ -120,7 +127,11 @@ const crumbs = breadcrumbs();
|
|
|
120
127
|
<nav class="mb-3 text-sm text-muted-foreground" aria-label="Breadcrumbs">
|
|
121
128
|
{crumbs.map((c, i) => (
|
|
122
129
|
<span>
|
|
123
|
-
|
|
130
|
+
{c.href ? (
|
|
131
|
+
<a href={c.href} class="hover:text-foreground hover:underline">{c.label}</a>
|
|
132
|
+
) : (
|
|
133
|
+
<span>{c.label}</span>
|
|
134
|
+
)}
|
|
124
135
|
{i < crumbs.length - 1 && <span class="mx-1.5">/</span>}
|
|
125
136
|
</span>
|
|
126
137
|
))}
|