diff --git a/astro.config.mjs b/astro.config.mjs index 9fbc5f0..83ad662 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -16,6 +16,7 @@ export default defineConfig({ starlight({ title: 'Xahau Docs', description: 'Documentation for the Xahau blockchain', + defaultLocale: 'root', locales: { root: { label: 'English', lang: 'en' }, es: { label: 'Español', lang: 'es' }, diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 479381d..f34550c 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,11 +1,9 @@ --- import { Image } from 'astro:assets' + import { getRelativeLocaleUrl } from 'astro:i18n' import logo from '../assets/xahau-logo.svg' - const LOCALES = ['es', 'ja'] - const firstSegment = Astro.url.pathname.split('/')[1] - const locale = LOCALES.includes(firstSegment) ? firstSegment : 'en' - const p = locale !== 'en' ? `/${locale}` : '' + const locale = Astro.currentLocale ?? 'en' const translations = { en: { @@ -78,7 +76,7 @@ class="flex-none container mx-auto py-12 max-w-7xl p-6 grid grid-cols-1 md:grid-cols-10 gap-4" >
- + Xahau

@@ -92,37 +90,53 @@

Xahau

- {t.about} - {t.features} - {t.ecosystem} - {t.roadmap} - {t.break} + {t.about} + {t.features} + {t.ecosystem} + {t.roadmap} + + {t.break} + {t.fraud} - {t.media} + + {t.media} + {t.privacy}

{t.docs}

- {t.getstarted} - {t.protocol} - Hooks - Data APIs - {t.infra} - Whitepaper + {t.getstarted} + + {t.protocol} + + Hooks + Data APIs + + {t.infra} + + + Whitepaper +

{t.connect}

- {t.events} - Dev Contest + {t.events} + Dev Contest X GitHub - {t.discord} + + {t.discord} +
diff --git a/src/components/Header.jsx b/src/components/Header.jsx index c8aed53..ce73576 100644 --- a/src/components/Header.jsx +++ b/src/components/Header.jsx @@ -21,7 +21,6 @@ import { useState } from 'react' import logo from '../assets/xahau-logo.svg' -const LOCALES = ['es', 'ja'] const languages = [ { code: 'en', label: 'English', flag: '🇬🇧' }, @@ -85,8 +84,7 @@ export default function Header(props) { const [mobileMenuOpen, setMobileMenuOpen] = useState(false) const pathname = props.url.pathname - const firstSegment = pathname.split('/')[1] - const currentLocale = LOCALES.includes(firstSegment) ? firstSegment : 'en' + const currentLocale = props.locale || 'en' const p = currentLocale !== 'en' ? `/${currentLocale}` : '' const t = nav[currentLocale] @@ -132,7 +130,7 @@ export default function Header(props) { ] const pathSegments = pathname.slice(1).split('/') - const activeSegment = LOCALES.includes(pathSegments[0]) + const activeSegment = currentLocale !== 'en' ? pathSegments[1] : pathSegments[0] diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index a5a256f..51cdbfc 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -3,8 +3,7 @@ import Footer from '../components/Footer.astro' import Header from '../components/Header.jsx' - const _firstSeg = Astro.url.pathname.split('/')[1] - const _lang = ['es', 'ja'].includes(_firstSeg) ? _firstSeg : 'en' + const _lang = Astro.currentLocale ?? 'en' const _canonicalURL = new URL(Astro.url.pathname, Astro.site) const _socialImageURL = new URL('/xahau-logo.png', Astro.site) const _title = Astro.props.frontmatter?.title @@ -41,7 +40,7 @@ -
+