---
import type { CollectionEntry } from "astro:content";
import { getPostUrlBySlug } from "@utils/url-utils";
import PostCard from "./PostCard.astro";

const { page } = Astro.props;

let delay = 0;
const interval = 50;
---

<div class="transition flex flex-col rounded-[var(--radius-large)] bg-transparent gap-4 mb-4">

    {page.data.map((entry: CollectionEntry<"posts">) => (
        <PostCard
                entry={entry}
                title={entry.data.title}
                published={entry.data.published}
                updated={entry.data.updated}
                url={getPostUrlBySlug(entry.slug)}
                image={entry.data.image}
                description={entry.data.description}
                draft={entry.data.draft}
                category={entry.data.category}
                class:list="onload-animation"
                style={`animation-delay: calc(var(--content-delay) + ${delay++ * interval}ms);`}
        ></PostCard>
    ))}
</div>