diff options
author | Cédric Bontems | 2023-07-04 00:06:16 +0200 |
---|---|---|
committer | GitHub | 2023-07-04 00:06:16 +0200 |
commit | 377a25dc4c51c060e751aeba4d3f946a41de907a (patch) | |
tree | 1750bbab18601bea5022564bc544a9840a8a2d92 | |
parent | d47639d50b53fa691c1d9b0f30f82ebf7f6ddf7e (diff) | |
download | IT.starlight-377a25dc4c51c060e751aeba4d3f946a41de907a.tar.gz IT.starlight-377a25dc4c51c060e751aeba4d3f946a41de907a.tar.bz2 IT.starlight-377a25dc4c51c060e751aeba4d3f946a41de907a.zip |
Fix broken link on 404 page when `defaultLocale: 'root'` is set (#300)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
-rw-r--r-- | .changeset/many-tips-battle.md | 5 | ||||
-rw-r--r-- | packages/starlight/404.astro | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/.changeset/many-tips-battle.md b/.changeset/many-tips-battle.md new file mode 100644 index 00000000..1e972e88 --- /dev/null +++ b/.changeset/many-tips-battle.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Fix broken link on 404 page when `defaultLocale: 'root'` is set in `astro.config.mjs` diff --git a/packages/starlight/404.astro b/packages/starlight/404.astro index ecd95447..cdf76156 100644 --- a/packages/starlight/404.astro +++ b/packages/starlight/404.astro @@ -6,7 +6,10 @@ import Page from './layout/Page.astro'; import type { StarlightDocsEntry } from './utils/routing'; import { useTranslations } from './utils/translations'; -const { lang = 'en', dir = 'ltr', locale } = config.defaultLocale || {}; +const { lang = 'en', dir = 'ltr' } = config.defaultLocale || {}; +let locale = config.defaultLocale?.locale; +if (locale === 'root') locale = undefined; + const entryMeta = { dir, lang, locale }; const t = useTranslations(locale); @@ -34,6 +37,6 @@ const entry = userEntry || fallbackEntry; const { Content, headings } = await entry.render(); --- -<Page {headings} entry={entry} slug={entry.slug} {...entryMeta} {entryMeta}> +<Page {headings} entry={entry} id={entry.id} slug={entry.slug} {...entryMeta} {entryMeta}> <Content /> </Page> |