@dogsbay/docs-layout 0.2.0-beta.7 → 0.2.0-beta.9
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/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.9",
|
|
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.9",
|
|
33
|
+
"@dogsbay/primitives": "0.2.0-beta.9"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"vitest": "^3.0.0"
|
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
|
))}
|