'use client'; import { useEffect, useState } from 'react'; import Slideshow from '@/components/Slideshow'; import CalendarStrip from '@/components/CalendarStrip'; import WeatherWidget from '@/components/WeatherWidget'; import LanguageSwitcher from '@/components/LanguageSwitcher'; import { t, useLanguage } from '@/lib/i18n'; const gold = '#E8A849'; const navy = '#010D1E'; const cream = '#f5f0e8'; const homeCopy = { en: { title: 'La Huasca', subtitle: 'A mountain retreat with warm hospitality and local flavor.', highlights: ['common.hotel', 'common.restaurant', 'common.andean_highlands'], }, es: { title: 'La Huasca', subtitle: 'Un refugio de montaña con hospitalidad cálida y sabor local.', highlights: ['common.hotel', 'common.restaurant', 'common.andean_highlands'], }, } as const; const fallbackTaglineKey = 'common.home_tagline'; export default function HomePage() { const language = useLanguage(); const [tagline, setTagline] = useState(t(fallbackTaglineKey, language)); useEffect(() => { let cancelled = false; const fallbackTagline = t(fallbackTaglineKey, language); setTagline(fallbackTagline); fetch('/api/site-assets?key=tagline') .then((r) => r.json()) .then((j) => { if (!cancelled && j.data) setTagline(j.data); }) .catch(() => {}); return () => { cancelled = true; }; }, [language]); const copy = homeCopy[language]; return (

{tagline}

{copy.title}

{copy.highlights.map((key, index) => ( {t(key, language)} {index < copy.highlights.length - 1 ? ' · ' : ''} ))}

{copy.subtitle}

); }