--- import { getEntry } from 'astro:content'; import BaseLayout from '../layouts/BaseLayout.astro'; import HomeBenefits from './home/HomeBenefits.astro'; import HomeDirector from './home/HomeDirector.astro'; import HomeEsa from './home/HomeEsa.astro'; import HomeFinancialHelp from './home/HomeFinancialHelp.astro'; import HomeHero from './home/HomeHero.astro'; import HomeInsurance from './home/HomeInsurance.astro'; import HomeProcess from './home/HomeProcess.astro'; import HomeServicesIntro from './home/HomeServicesIntro.astro'; import HomeSkills from './home/HomeSkills.astro'; import HomeTestimonials from './home/HomeTestimonials.astro'; import type { HomePageContent, HomeSection } from '../types/home-sections'; interface Props { lang?: string } const { lang = 'en' } = Astro.props; const es = lang === 'es'; const entry = await getEntry('pages', es ? 'es/index' : 'en/index'); if (!entry) throw new Error(`[HomePage] Content entry not found for lang="${lang}". If running in dev, restart the dev server to rebuild the content layer cache.`); const { title, description, canonical } = entry.data; function fromHomeContent(home: HomePageContent): HomeSection[] { return [ { type: 'hero', ...home.hero }, { type: 'services-intro', ...home.servicesIntro }, { type: 'benefits', ...home.benefits }, { type: 'skills', ...home.skills }, { type: 'insurance', ...home.insurance }, { type: 'esa', ...home.esa }, { type: 'financial-help', ...home.financialHelp }, { type: 'process', ...home.process }, { type: 'director', ...home.director }, { type: 'testimonials', ...home.testimonials }, ]; } const sections: HomeSection[] = entry.data.home ? fromHomeContent(entry.data.home) : ((entry.data.sections ?? []) as HomeSection[]); --- {sections.map((section) => { switch (section.type) { case 'hero': return ; case 'services-intro': return ; case 'benefits': return ; case 'skills': return ; case 'insurance': return ; case 'esa': return ; case 'financial-help': return ; case 'process': return ; case 'director': return ; case 'testimonials': return ; default: return null; } })}