Skip to content

Commit

Permalink
Add locale to SiteTitle link (#57)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
  • Loading branch information
BryceRussell and delucis authored May 17, 2023
1 parent 0040a06 commit 5b6cccb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-forks-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/starlight": patch
---

Update site title link to include locale
6 changes: 4 additions & 2 deletions packages/starlight/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
12 changes: 11 additions & 1 deletion packages/starlight/components/SiteTitle.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 && (
<>
Expand Down

0 comments on commit 5b6cccb

Please sign in to comment.