---
import DefaultPageLayout from "../layouts/default.astro";
import PostPreviewList from "../components/PostPreviewList.astro";
import HeroContent from "../components/HeroContent.astro";
import { getPosts, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api";
const { posts } = await getPosts();
const settings = await getSettings();
invariant(settings, 'Settings not found');
const title = settings.title;
const description = settings.description;
---

<DefaultPageLayout
  content={{ title, description }}
  settings={settings}
  bodyClass={"home-template"}
>
  <HeroContent
    mainTitle={settings.title}
    description={settings.description}
    featureImg={settings?.cover_image || ""}
    settings={settings}
    addClass={"hero-cta bg-gradient"}
  />

  <main id="site-main" class="site-main outer">
    <div class="inner posts">
      <PostPreviewList posts={posts} settings={settings} isHome={true} />
    </div>
  </main>
</DefaultPageLayout>
