@astrojs/starlight 0.29.1 → 0.29.2
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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.29.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2616](https://github.com/withastro/starlight/pull/2616) [`128cc51`](https://github.com/withastro/starlight/commit/128cc51b416a1a934eabb1989c04b76517e77a04) Thanks [@delucis](https://github.com/delucis)! - Fixes an edge case to correctly avoid a trailing slash when navigating from a root locale homepage to another language via Starlight’s language switcher when `trailingSlash: 'never'` is set
|
|
8
|
+
|
|
3
9
|
## 0.29.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/components/Head.astro
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { z } from 'astro/zod';
|
|
3
|
+
import context from 'virtual:starlight/project-context';
|
|
3
4
|
import config from 'virtual:starlight/user-config';
|
|
4
5
|
import { version } from '../package.json';
|
|
5
6
|
import type { HeadConfigSchema } from '../schemas/head';
|
|
@@ -66,7 +67,7 @@ if (canonical && config.isMultilingual) {
|
|
|
66
67
|
attrs: {
|
|
67
68
|
rel: 'alternate',
|
|
68
69
|
hreflang: localeOpts.lang,
|
|
69
|
-
href: localizedUrl(canonical, locale).href,
|
|
70
|
+
href: localizedUrl(canonical, locale, context.trailingSlash).href,
|
|
70
71
|
},
|
|
71
72
|
});
|
|
72
73
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import context from 'virtual:starlight/project-context';
|
|
2
3
|
import config from 'virtual:starlight/user-config';
|
|
3
4
|
import { localizedUrl } from '../utils/localizedUrl';
|
|
4
5
|
import Select from './Select.astro';
|
|
@@ -8,7 +9,7 @@ import type { Props } from '../props';
|
|
|
8
9
|
* Get the equivalent of the current page path for the passed locale.
|
|
9
10
|
*/
|
|
10
11
|
function localizedPathname(locale: string | undefined): string {
|
|
11
|
-
return localizedUrl(Astro.url, locale).pathname;
|
|
12
|
+
return localizedUrl(Astro.url, locale, context.trailingSlash).pathname;
|
|
12
13
|
}
|
|
13
14
|
---
|
|
14
15
|
|
package/package.json
CHANGED
package/utils/localizedUrl.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import config from 'virtual:starlight/user-config';
|
|
2
2
|
import { stripTrailingSlash } from './path';
|
|
3
|
+
import type { AstroConfig } from 'astro';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Get the equivalent of the passed URL for the passed locale.
|
|
6
7
|
*/
|
|
7
|
-
export function localizedUrl(
|
|
8
|
+
export function localizedUrl(
|
|
9
|
+
url: URL,
|
|
10
|
+
locale: string | undefined,
|
|
11
|
+
trailingSlash: AstroConfig['trailingSlash']
|
|
12
|
+
): URL {
|
|
8
13
|
// Create a new URL object to void mutating the global.
|
|
9
14
|
url = new URL(url);
|
|
10
15
|
if (!config.locales) {
|
|
@@ -41,5 +46,6 @@ export function localizedUrl(url: URL, locale: string | undefined): URL {
|
|
|
41
46
|
}
|
|
42
47
|
// Restore base
|
|
43
48
|
if (hasBase) url.pathname = base + url.pathname;
|
|
49
|
+
if (trailingSlash === 'never') url.pathname = stripTrailingSlash(url.pathname);
|
|
44
50
|
return url;
|
|
45
51
|
}
|