From 3bc68ca067f3a96b29df39404448a0d1c918cae9 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Sat, 6 Sep 2025 14:31:18 -0400 Subject: [PATCH] refactor(nav): drop navFor; build localized nav links with astro:i18n getRelativeLocaleUrl; update README --- README.md | 2 +- dist/index.html | 2 +- src/i18n/routes.ts | 16 ---------------- src/layouts/BaseLayout.astro | 20 ++++++++++++++++---- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index acf3480..8e79725 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This site is built with Astro and Tailwind, with FR/EN locales. The legacy Pytho - `src/pages/fr|en/`: localized pages (Home, Apartments, Reviews, Rates, Contact, Policies). - `src/layouts/`: shared layout with sticky header, language toggle, footer. - `src/styles/global.css`: Tailwind v4 with brand tokens (`--color-brand`, `--color-brand-600`). -- `src/i18n/routes.ts`: route manifest (`hrefFor`, `siblingPath`, `navFor`). +- `src/i18n/routes.ts`: route manifest (`siblingPath`, CTA label helper). - `public/`: static assets + `_redirects` (root → `/fr/`). - Spec: `docs/spec/website-revamp-spec.md` (goals, sitemap, copy, release plan). diff --git a/dist/index.html b/dist/index.html index e6797cf..a08af22 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1 +1 @@ -Redirecting to: /fr Redirecting from / to /fr \ No newline at end of file +Redirecting to: /fr/ Redirecting from / to /fr/ \ No newline at end of file diff --git a/src/i18n/routes.ts b/src/i18n/routes.ts index c965b52..7cd2462 100644 --- a/src/i18n/routes.ts +++ b/src/i18n/routes.ts @@ -46,22 +46,6 @@ export const routes: Record> = { }, }; -export function navFor(locale: Locale): Array<{ label: string; href: string }> { - return locale === "en" - ? [ - { label: "Apartments", href: routes.apartments.en }, - { label: "Reviews", href: routes.reviews.en }, - { label: "Location & Access", href: routes.location.en }, - { label: "Rates", href: routes.rates.en }, - ] - : [ - { label: "Appartements", href: routes.apartments.fr }, - { label: "Avis", href: routes.reviews.fr }, - { label: "Accès", href: routes.location.fr }, - { label: "Tarifs", href: routes.rates.fr }, - ]; -} - export function ctaLabelFor(locale: Locale): string { return locale === "en" ? "Send a Request" : "Envoyer une demande"; } diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 7ad4a99..b73789a 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -1,11 +1,23 @@ --- import '../styles/global.css'; -import { navFor, ctaLabelFor } from '../i18n/routes'; +import { ctaLabelFor } from '../i18n/routes'; import { getRelativeLocaleUrl } from 'astro:i18n'; const { title = 'VillaFleurie', lang = 'fr', description = 'Séjours confortables au Gosier pour couples et petites familles' } = Astro.props; -const altFr = "/fr/" -const altEn = "/en/" -const nav = navFor(lang); +const altFr = "/fr/"; +const altEn = "/en/"; +const nav = lang === 'en' + ? [ + { label: 'Apartments', href: getRelativeLocaleUrl('en', '/apartments/') }, + { label: 'Reviews', href: getRelativeLocaleUrl('en', '/reviews/') }, + { label: 'Location & Access', href: getRelativeLocaleUrl('en', '/location-access/') }, + { label: 'Rates', href: getRelativeLocaleUrl('en', '/rates-availability/') }, + ] + : [ + { label: 'Appartements', href: getRelativeLocaleUrl('fr', '/appartements/') }, + { label: 'Avis', href: getRelativeLocaleUrl('fr', '/avis/') }, + { label: 'Accès', href: getRelativeLocaleUrl('fr', '/acces/') }, + { label: 'Tarifs', href: getRelativeLocaleUrl('fr', '/tarifs-disponibilites/') }, + ]; const ctaLabel = ctaLabelFor(lang); const homeHref = getRelativeLocaleUrl(lang, '/'); ---