Files
aia-website/www/src/components/pages/HomePage.astro
T

67 lines
2.4 KiB
Plaintext

---
import type { CollectionEntry } 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 { entry: CollectionEntry<'pages'> }
const { entry } = Astro.props;
const { title, description, lang } = 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[]);
---
<BaseLayout {title} {description} {lang}>
{sections.map((section) => {
switch (section.type) {
case 'hero':
return <HomeHero section={section} />;
case 'services-intro':
return <HomeServicesIntro section={section} />;
case 'benefits':
return <HomeBenefits section={section} />;
case 'skills':
return <HomeSkills section={section} />;
case 'insurance':
return <HomeInsurance section={section} />;
case 'esa':
return <HomeEsa section={section} />;
case 'financial-help':
return <HomeFinancialHelp section={section} />;
case 'process':
return <HomeProcess section={section} />;
case 'director':
return <HomeDirector section={section} />;
case 'testimonials':
return <HomeTestimonials section={section} />;
default:
return null;
}
})}
</BaseLayout>