@dogsbay/docs-layout 0.2.0-beta.17 → 0.2.0-beta.171
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 +17 -6
- package/src/AnnouncementBar.astro +38 -0
- package/src/BlogIndex.astro +179 -0
- package/src/DocsFooter.astro +110 -16
- package/src/DocsLayout.astro +806 -72
- package/src/DocsNavClient.astro +119 -0
- package/src/DocsToc.astro +1 -1
- package/src/HeaderLinks.astro +80 -0
- package/src/LocaleSwitcher.astro +2 -2
- package/src/PageActions.astro +8 -2
- package/src/ProductSwitcher.astro +63 -0
- package/src/SearchDialog.astro +323 -36
- package/src/SocialLinks.astro +34 -0
- package/src/TagList.astro +24 -3
- package/src/VersionSwitcher.astro +31 -6
- package/src/docs-nav-client.ts +439 -0
- package/src/json-ld.ts +4 -53
- package/src/link-icons.ts +54 -0
- package/src/markdown-negotiation.ts +38 -2
- package/src/nav-filter.ts +68 -127
- package/src/pagefind-base-url.ts +59 -0
- package/src/pagination.ts +7 -3
- package/src/search-facets.ts +24 -205
- package/src/section-switcher.ts +71 -0
- package/src/site-chrome.ts +63 -0
- package/src/switcher.ts +248 -6
- package/src/tag-list-data.ts +30 -35
- package/src/toc-kind.css +10 -10
- package/src/toc-placement.ts +71 -0
- package/src/version-redirect.ts +17 -4
package/src/version-redirect.ts
CHANGED
|
@@ -31,6 +31,15 @@ export interface AxisRedirectConfig {
|
|
|
31
31
|
defaultVersion?: string;
|
|
32
32
|
/** Full set of declared version ids. Empty/undefined → axis inactive. */
|
|
33
33
|
knownVersions?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* The version served at the site root (`versions[].path: ""`, the
|
|
36
|
+
* default version). A URL with no version segment is one of its pages,
|
|
37
|
+
* so the version is never injected; a URL starting with another known
|
|
38
|
+
* version's segment is that version's (the longest matching prefix
|
|
39
|
+
* wins). Only the locale redirect remains. format-astro emits no version
|
|
40
|
+
* config at all in that case; this keeps the helper right when given one.
|
|
41
|
+
*/
|
|
42
|
+
rootVersion?: string;
|
|
34
43
|
/** Default locale id; required when locale axis is active. */
|
|
35
44
|
defaultLocale?: string;
|
|
36
45
|
/** Full set of declared locale ids. Empty/undefined → axis inactive. */
|
|
@@ -126,7 +135,8 @@ export function shouldRedirectToDefaultVersion(
|
|
|
126
135
|
if (
|
|
127
136
|
versionAxisActive &&
|
|
128
137
|
cursor < segments.length &&
|
|
129
|
-
knownVersions.has(segments[cursor])
|
|
138
|
+
knownVersions.has(segments[cursor]) &&
|
|
139
|
+
segments[cursor] !== config.rootVersion
|
|
130
140
|
) {
|
|
131
141
|
presentVersion = segments[cursor];
|
|
132
142
|
cursor += 1;
|
|
@@ -134,13 +144,16 @@ export function shouldRedirectToDefaultVersion(
|
|
|
134
144
|
|
|
135
145
|
// What's the rest of the path beyond the recognised axis prefixes?
|
|
136
146
|
const tailSegments = segments.slice(cursor);
|
|
147
|
+
// With a root version, a URL without a version segment is already complete.
|
|
148
|
+
const versionMissing =
|
|
149
|
+
versionAxisActive && presentVersion === undefined && !config.rootVersion;
|
|
137
150
|
if (tailSegments.length === 0) {
|
|
138
151
|
// The path is JUST a known axis prefix (e.g. /docs/en/ or
|
|
139
152
|
// /docs/v1/). Treat as the axis's landing page; no redirect
|
|
140
153
|
// needed unless other axes are MISSING from the URL too.
|
|
141
154
|
if (
|
|
142
155
|
(localeAxisActive && presentLocale === undefined) ||
|
|
143
|
-
|
|
156
|
+
versionMissing
|
|
144
157
|
) {
|
|
145
158
|
// Some axis still missing — fall through to redirect.
|
|
146
159
|
} else {
|
|
@@ -150,7 +163,7 @@ export function shouldRedirectToDefaultVersion(
|
|
|
150
163
|
|
|
151
164
|
// If all required-active axes are present, no redirect needed.
|
|
152
165
|
const localeNeeded = localeAxisActive && presentLocale === undefined;
|
|
153
|
-
const versionNeeded =
|
|
166
|
+
const versionNeeded = versionMissing;
|
|
154
167
|
if (!localeNeeded && !versionNeeded) return null;
|
|
155
168
|
|
|
156
169
|
// Compose the redirect target with missing segments injected
|
|
@@ -159,7 +172,7 @@ export function shouldRedirectToDefaultVersion(
|
|
|
159
172
|
if (localeAxisActive) {
|
|
160
173
|
out.push(presentLocale ?? config.defaultLocale!);
|
|
161
174
|
}
|
|
162
|
-
if (versionAxisActive) {
|
|
175
|
+
if (versionAxisActive && (presentVersion !== undefined || !config.rootVersion)) {
|
|
163
176
|
out.push(presentVersion ?? config.defaultVersion!);
|
|
164
177
|
}
|
|
165
178
|
out.push(...tailSegments);
|