From 5b6cccb7f9ee5810c75fbbb45496e2a1d022f7dd Mon Sep 17 00:00:00 2001 From: Bryce Russell Date: Wed, 17 May 2023 02:27:02 -0500 Subject: Add locale to SiteTitle link (#57) Co-authored-by: Chris Swithinbank --- .changeset/tidy-forks-taste.md | 5 +++++ packages/starlight/components/Header.astro | 6 ++++-- packages/starlight/components/SiteTitle.astro | 12 +++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 .changeset/tidy-forks-taste.md diff --git a/.changeset/tidy-forks-taste.md b/.changeset/tidy-forks-taste.md new file mode 100644 index 00000000..3e7b96e5 --- /dev/null +++ b/.changeset/tidy-forks-taste.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Update site title link to include locale diff --git a/packages/starlight/components/Header.astro b/packages/starlight/components/Header.astro index 565f2503..13bf4ba3 100644 --- a/packages/starlight/components/Header.astro +++ b/packages/starlight/components/Header.astro @@ -8,15 +8,17 @@ import ThemeSelect from './ThemeSelect.astro'; interface Props { locale: string | undefined; } + +const { locale } = Astro.props ---
- +
diff --git a/packages/starlight/components/SiteTitle.astro b/packages/starlight/components/SiteTitle.astro index 737b4fe2..0a4472aa 100644 --- a/packages/starlight/components/SiteTitle.astro +++ b/packages/starlight/components/SiteTitle.astro @@ -2,6 +2,10 @@ import { logos } from 'virtual:starlight/user-images'; import config from 'virtual:starlight/user-config'; +interface Props { + locale: string | undefined; +} + if (config.logo) { let err: string | undefined; if ('src' in config.logo) { @@ -17,9 +21,15 @@ if (config.logo) { } if (err) throw new Error(err); } + +const { locale } = Astro.props + +const href = locale + ? `${import.meta.env.BASE_URL.replace(/\/$/, '')}/${locale}/` + : import.meta.env.BASE_URL --- - + { config.logo && logos.dark && ( <> -- cgit