---
import { getCollection } from "astro:content";
import { SITE, POSTS } from "@consts";
import ShowcasePost from "@components/ShowcasePost.astro";
import Layout from "@layouts/Layout.astro";

const posts = (await getCollection("posts"))
  .filter((post) => !post.data.draft)
  .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
---

<Layout title={SITE.TITLE} description={POSTS.DESCRIPTION}>
  <h1 class="animate-reveal break-words text-4xl font-semibold opacity-0">
    {POSTS.TITLE}
  </h1>
  <ol
    class="mt-16 grid animate-reveal grid-cols-1 gap-6 opacity-0 [animation-delay:0.1s]"
  >
    {posts.map((article: any) => <ShowcasePost collection={article} />)}
  </ol>
</Layout>
