diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index f7a5070..aa7be6c 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -20,11 +20,12 @@ const canonicalUrl = Astro.url.toString(); --- - + + @@ -46,7 +47,7 @@ const canonicalUrl = Astro.url.toString(); rel="stylesheet" /> - + diff --git a/src/pages/en/index.astro b/src/pages/en/index.astro index 8ed3bf2..aed5467 100644 --- a/src/pages/en/index.astro +++ b/src/pages/en/index.astro @@ -2,4 +2,4 @@ import Page from '../index.astro'; --- - + diff --git a/src/pages/index.astro b/src/pages/index.astro index 014f4eb..0ed2009 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -16,10 +16,19 @@ import { getFaq, getCta, } from '../data/home'; +import type { SupportedLocale } from '../data/home/navigation'; +interface Props { + /** Locale esplicito dalle route /en e /th (evita ambiguità se la page è importata come componente). */ + locale?: SupportedLocale; +} + +const { locale: localeProp } = Astro.props; const path = Astro.url.pathname; const localeMatch = path.match(/^\/(en|th)(\/|$)/); -const currentLocale = (localeMatch?.[1] ?? 'it') as 'it' | 'en' | 'th'; +const currentLocale = (localeProp ?? + (localeMatch?.[1] as SupportedLocale | undefined) ?? + 'it') as SupportedLocale; const navigation = getNavigation(currentLocale); const siteMeta = getSiteMeta(currentLocale); const hero = getHero(currentLocale); diff --git a/src/pages/th/index.astro b/src/pages/th/index.astro index 8ed3bf2..f393f31 100644 --- a/src/pages/th/index.astro +++ b/src/pages/th/index.astro @@ -2,4 +2,4 @@ import Page from '../index.astro'; --- - + diff --git a/src/scripts/nx-nav-spy.ts b/src/scripts/nx-nav-spy.ts index ac1e0aa..a1aebdb 100644 --- a/src/scripts/nx-nav-spy.ts +++ b/src/scripts/nx-nav-spy.ts @@ -75,8 +75,11 @@ function measureHeaderAndSync(): void { } function bind(): void { - const path = window.location.pathname; - if (path !== '/' && path !== '/index.html') return; + const path = window.location.pathname.replace(/\/$/, '') || '/'; + // Home IT (`/`) e home localizzate (`/en`, `/th`). + if (path !== '/' && path !== '/index.html' && path !== '/en' && path !== '/th') { + return; + } const header = document.querySelector('header'); measureHeaderAndSync();