refactor(components): separate page shells from reusable components
Additional info: - move page-specific shells into src/components/pages/ - keep reusable building blocks and home sections in their existing component folders - update PageLayout and the home route imports to the new page-shell paths - preserve current page behavior while making the component tree easier to navigate
This commit is contained in:
9 files changed
+20
-20
No files matched your search
@@ -0,0 +1,69 @@
|
||||
---
|
||||
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[]);
|
||||
---
|
||||
<BaseLayout {title} {description} {canonical} {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>
|
||||
Reference in new issue
Block a user