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
|
||||
? fromHomeContent(entry.data.home)
|
||||
: ((entry.data.sections ?? []) as HomeSection[]);
|
||||
|
||||
function renderSection(section: HomeSection) {
|
||||
---
|
||||
<BaseLayout {title} {description} {canonical} {lang}>
|
||||
{sections.map((section) => {
|
||||
switch (section.type) {
|
||||
case 'hero':
|
||||
return <HomeHero section={section} />;
|
||||
@@ -61,11 +62,8 @@ function renderSection(section: HomeSection) {
|
||||
return <HomeDirector section={section} />;
|
||||
case 'testimonials':
|
||||
return <HomeTestimonials section={section} />;
|
||||
}
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
---
|
||||
<BaseLayout {title} {description} {canonical} {lang}>
|
||||
{sections.map(renderSection)}
|
||||
})}
|
||||
</BaseLayout>
|
||||
|
||||
Reference in New Issue
Block a user