refactor(nav): drop navFor; build localized nav links with astro:i18n getRelativeLocaleUrl; update README

This commit is contained in:
Ruidy 2025-09-06 14:31:18 -04:00
parent 7613249b56
commit 3bc68ca067
4 changed files with 18 additions and 22 deletions

View file

@ -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).

2
dist/index.html vendored
View file

@ -1 +1 @@
<!doctype html><title>Redirecting to: /fr</title><meta http-equiv="refresh" content="0;url=/fr"><meta name="robots" content="noindex"><link rel="canonical" href="/fr"><body> <a href="/fr">Redirecting from <code>/</code> to <code>/fr</code></a></body>
<!doctype html><title>Redirecting to: /fr/</title><meta http-equiv="refresh" content="2;url=/fr/"><meta name="robots" content="noindex"><link rel="canonical" href="/fr/"><body> <a href="/fr/">Redirecting from <code>/</code> to <code>/fr/</code></a></body>

View file

@ -46,22 +46,6 @@ export const routes: Record<RouteKey, Record<Locale, string>> = {
},
};
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";
}

View file

@ -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, '/');
---