---
import { getCollection } from "astro:content"
import PageLayout from "../../layouts/PageLayout.astro";
import {astroI18n, t} from "astro-i18n";
import moment from "moment";
import PostComponent from "../../components/PostComponent.astro";

const posts = (await getCollection("announcements", (entry) => entry.id.split("/")[0] === astroI18n.locale))
    .sort((a, b) => moment(b.data.created).unix() - moment(a.data.created).unix());

---

<PageLayout title={t("blog.title")}>
    {posts.map((post, index) => (
        <div>
            <PostComponent post={post} />
            {index !== posts.length - 1 && <hr/>}
        </div>
    ))}
</PageLayout>