From 6cf3d3c8532822083aca13d3b5648eabe193d99e Mon Sep 17 00:00:00 2001 From: Ruidy Date: Fri, 5 Sep 2025 11:40:41 -0400 Subject: [PATCH] feat(i18n): add language toggle and hreflang alternates; compute sibling FR/EN paths in layout --- src/layouts/BaseLayout.astro | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index d52494e..41d4a3a 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -1,6 +1,11 @@ --- import '../styles/global.css'; const { title = 'VillaFleurie', lang = 'fr', description = 'Séjours confortables au Gosier pour couples et petites familles' } = Astro.props; +const pathname = Astro.url.pathname; +const toFr = (p: string) => p.startsWith('/en/') ? `/fr/${p.slice(4)}` : (p.startsWith('/fr/') ? p : '/fr/'); +const toEn = (p: string) => p.startsWith('/fr/') ? `/en/${p.slice(4)}` : (p.startsWith('/en/') ? p : '/en/'); +const altFr = toFr(pathname); +const altEn = toEn(pathname); --- @@ -10,6 +15,9 @@ const { title = 'VillaFleurie', lang = 'fr', description = 'Séjours confortable {title} · VillaFleurie + + +
@@ -24,6 +32,11 @@ const { title = 'VillaFleurie', lang = 'fr', description = 'Séjours confortable Accès Tarifs Envoyer une demande +
+ FR + | + EN +