Add webpage component with Hero component

This commit is contained in:
itsfinniii
2026-03-20 18:07:16 +01:00
parent 423a4b74dd
commit 50dc6ec4c0
3 changed files with 77 additions and 18 deletions

View File

@@ -0,0 +1,33 @@
---
import { Image } from 'astro:assets';
interface Props {
hero: HeroComponent;
}
const hero = Astro.props.hero;
console.log(hero);
---
<div id={`hero-${hero.id}`} class="flex w-full">
<div class="flex w-full h-screen static">
<Image
src={hero.backgroundImage.url}
width={hero.backgroundImage.width}
height={hero.backgroundImage.height}
class="flex w-full h-screen object-cover z-1"
alt=""
/>
<div class="absolute flex items-center w-full h-screen bg-[#00000082] z-10">
<div class="absolute text-white md:left-40 sm:left-20 p-8 z-30">
<div class="flex flex-col gap-2.5 text-left">
<h1 class="text-white font-bold text-8xl w-fit">{hero.title}</h1>
{ hero.text !== null && (
<div class="text-2xl max-w-170">{hero.text}</div>
) }
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,19 @@
---
import Hero from '../web/Hero.astro';
interface Props {
webpage: WebpageComponent[];
}
const components = Astro.props.webpage;
console.log(Astro.props.webpage);
---
<div class="flex flex-col">
{ components.map((component) => (
<Fragment>
{ component.component === "Hero" && <Hero hero={component} /> }
</Fragment>
)) }
</div>

View File

@@ -3,8 +3,11 @@ import { getAllRoutesList } from "@/lib/routing";
import { getPage } from "@/lib/pages"; import { getPage } from "@/lib/pages";
import { getSettings } from "@/content/settings/settings" import { getSettings } from "@/content/settings/settings"
import WebpageLayout from "@/layouts/WebpageLayout.astro"; import WebpageLayout from "@/layouts/WebpageLayout.astro";
import BlogLayout from "@/layouts/BlogLayout.astro";
import ProjectLayout from "@/layouts/ProjectLayout.astro";
import BlogIndex from "@/components/blogs/BlogIndex.astro"; import BlogIndex from "@/components/blogs/BlogIndex.astro";
import ProjectIndex from "@/components/projects/ProjectIndex.astro"; import ProjectIndex from "@/components/projects/ProjectIndex.astro";
import Webpage from "@/components/webpage/Webpage.astro";
export async function getStaticPaths() { export async function getStaticPaths() {
const settings = await getSettings(); const settings = await getSettings();
@@ -45,12 +48,12 @@ if (page === null || page.page === null) {
} }
}}}> }}}>
<Fragment slot="content"> <Fragment slot="content">
<div>Webpage</div> <Webpage webpage={page.page.components} />
</Fragment> </Fragment>
</WebpageLayout> </WebpageLayout>
) } ) }
{ page.pageType === "BlogIndex" && ( { page.page.type === "BlogIndex" && (
<WebpageLayout settings={{ <WebpageLayout settings={{
searchEngine: { searchEngine: {
title: "Blogs", title: "Blogs",
@@ -65,32 +68,34 @@ if (page === null || page.page === null) {
} }
}}}> }}}>
<Fragment slot="content"> <Fragment slot="content">
<BlogIndex page={page.page as BlogIndex} /> <BlogIndex page={page.page} />
</Fragment> </Fragment>
</WebpageLayout> </WebpageLayout>
) } ) }
{ page?.pageType === "BlogPost" && ( { page.page.type === "BlogPost" && (
<WebpageLayout settings={{ <BlogLayout settings={{
searchEngine: { searchEngine: {
title: "Blogs", title: page.page.searchEngine.title,
description: "", description: page.page.searchEngine.description,
allowCrawlers: true, allowCrawlers: page.page.searchEngine.allowCrawlers,
canonical: null, canonical: page.page.searchEngine.canonical,
priority: 65, priority: page.page.searchEngine.priority,
thumbnail: { thumbnail: {
url: "", url: page.page.searchEngine.thumbnail.url,
width: 1200, width: 1200,
height: 630 height: 630
} }
}}}> },
tags: []
}}>
<Fragment slot="content"> <Fragment slot="content">
<dib>BlogPost</dib> <dib>BlogPost</dib>
</Fragment> </Fragment>
</WebpageLayout> </BlogLayout>
) } ) }
{ page.pageType === "ProjectIndex" && ( { page.page.type === "ProjectIndex" && (
<WebpageLayout settings={{ <WebpageLayout settings={{
searchEngine: { searchEngine: {
title: "Projects", title: "Projects",
@@ -110,8 +115,8 @@ if (page === null || page.page === null) {
</WebpageLayout> </WebpageLayout>
) } ) }
{ page.pageType === "ProjectPost" && ( { page.page.type === "ProjectPost" && (
<WebpageLayout settings={{ <ProjectLayout settings={{
searchEngine: { searchEngine: {
title: "Projects", title: "Projects",
description: "", description: "",
@@ -123,11 +128,13 @@ if (page === null || page.page === null) {
width: 1200, width: 1200,
height: 630 height: 630
} }
}}}> },
tags: []
}}>
<Fragment slot="content"> <Fragment slot="content">
<div>ProjectPost</div> <div>ProjectPost</div>
</Fragment> </Fragment>
</WebpageLayout> </ProjectLayout>
) } ) }
{ page.pageType === "PhotoCategoryIndex" && ( { page.pageType === "PhotoCategoryIndex" && (