@dogsbay/docs-layout 0.2.0-beta.20 → 0.2.0-beta.22
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 +18 -2
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.22",
|
|
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.22",
|
|
33
|
+
"@dogsbay/primitives": "0.2.0-beta.22"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"vitest": "^3.0.0"
|
package/src/DocsLayout.astro
CHANGED
|
@@ -481,9 +481,25 @@ const currentPath = Astro.url.pathname.replace(/\/$/, "") || "/";
|
|
|
481
481
|
const metaDescription = description ?? siteDescription;
|
|
482
482
|
const metaOgImage = ogImage ?? defaultOgImage;
|
|
483
483
|
const isAbsoluteSiteUrl = /^https?:\/\//.test(siteUrl);
|
|
484
|
+
// Compose canonical from ORIGIN + pathname. siteUrl may carry a
|
|
485
|
+
// path component (the urlBase that drives Astro's `base` — see
|
|
486
|
+
// plans/astro-base-from-site-url.md), and Astro.url.pathname
|
|
487
|
+
// already includes that prefix. Naively concatenating siteUrl +
|
|
488
|
+
// pathname double-counts the urlBase (e.g. .../repo/repo/page).
|
|
489
|
+
// Strip path off siteUrl by reparsing as a URL.
|
|
490
|
+
let canonicalOrigin: string | undefined;
|
|
491
|
+
if (isAbsoluteSiteUrl) {
|
|
492
|
+
try {
|
|
493
|
+
const u = new URL(siteUrl);
|
|
494
|
+
canonicalOrigin = `${u.protocol}//${u.host}`;
|
|
495
|
+
} catch {
|
|
496
|
+
// Malformed siteUrl — fall back to the original (no path) behavior.
|
|
497
|
+
canonicalOrigin = siteUrl.replace(/\/$/, "");
|
|
498
|
+
}
|
|
499
|
+
}
|
|
484
500
|
const computedCanonical = canonicalUrl
|
|
485
|
-
?? (
|
|
486
|
-
?
|
|
501
|
+
?? (canonicalOrigin
|
|
502
|
+
? canonicalOrigin + Astro.url.pathname
|
|
487
503
|
: undefined);
|
|
488
504
|
|
|
489
505
|
// Markdown mirror — append `.md` to the current path for the alternate link
|