diff options
author | Bryce Russell | 2023-05-17 02:27:02 -0500 |
---|---|---|
committer | GitHub | 2023-05-17 09:27:02 +0200 |
commit | 5b6cccb7f9ee5810c75fbbb45496e2a1d022f7dd (patch) | |
tree | 8759a74795a382d349ce2723aef1e10bb80965ab | |
parent | 0040a06a4dcea9348222617080410823d74dae09 (diff) | |
download | IT.starlight-5b6cccb7f9ee5810c75fbbb45496e2a1d022f7dd.tar.gz IT.starlight-5b6cccb7f9ee5810c75fbbb45496e2a1d022f7dd.tar.bz2 IT.starlight-5b6cccb7f9ee5810c75fbbb45496e2a1d022f7dd.zip |
Add locale to SiteTitle link (#57)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
-rw-r--r-- | .changeset/tidy-forks-taste.md | 5 | ||||
-rw-r--r-- | packages/starlight/components/Header.astro | 6 | ||||
-rw-r--r-- | packages/starlight/components/SiteTitle.astro | 12 |
3 files changed, 20 insertions, 3 deletions
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 --- <div class="header"> - <SiteTitle /> + <SiteTitle {locale} /> <Search /> <div class="hidden md:flex right-group"> <SocialIcons /> <ThemeSelect /> - <LanguageSelect locale={Astro.props.locale} /> + <LanguageSelect {locale}/> </div> </div> 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 --- -<a href={import.meta.env.BASE_URL} class="site-title flex"> +<a {href} class="site-title flex"> { config.logo && logos.dark && ( <> |