fix(homepage): move section rendering into the Astro template
- keep homepage section data driven from structured frontmatter - render typed section components inside the template map instead of frontmatter helper code - resolve the Astro parse error in HomePage.astro - preserve the existing homepage section order and component split
This commit is contained in:
@@ -38,8 +38,9 @@ function fromHomeContent(home: HomePageContent): HomeSection[] {
|
|||||||
const sections: HomeSection[] = entry.data.home
|
const sections: HomeSection[] = entry.data.home
|
||||||
? fromHomeContent(entry.data.home)
|
? fromHomeContent(entry.data.home)
|
||||||
: ((entry.data.sections ?? []) as HomeSection[]);
|
: ((entry.data.sections ?? []) as HomeSection[]);
|
||||||
|
---
|
||||||
function renderSection(section: HomeSection) {
|
<BaseLayout {title} {description} {canonical} {lang}>
|
||||||
|
{sections.map((section) => {
|
||||||
switch (section.type) {
|
switch (section.type) {
|
||||||
case 'hero':
|
case 'hero':
|
||||||
return <HomeHero section={section} />;
|
return <HomeHero section={section} />;
|
||||||
@@ -61,11 +62,8 @@ function renderSection(section: HomeSection) {
|
|||||||
return <HomeDirector section={section} />;
|
return <HomeDirector section={section} />;
|
||||||
case 'testimonials':
|
case 'testimonials':
|
||||||
return <HomeTestimonials section={section} />;
|
return <HomeTestimonials section={section} />;
|
||||||
}
|
default:
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
---
|
})}
|
||||||
<BaseLayout {title} {description} {canonical} {lang}>
|
|
||||||
{sections.map(renderSection)}
|
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user