---
import { getCollection } from "astro:content";
import ContentLayout from "@/layouts/content.astro";
import { BlogHeader } from "@/components/blog/header";
import TagList from "@/components/blog/tag-list";

const posts = (await getCollection("blog", ({ data }) => {
  return import.meta.env.DEV || data.isDraft !== true;
})).sort((a, b) => {
  return b.data.date.valueOf() - a.data.date.valueOf()
}).map(post => ({
  ...post,
  data: {
    ...post.data,
    date: post.data.date.toLocaleDateString("en-US", {
      year: "numeric",
      month: "long",
      day: "numeric"
    })
  }
}));
---
<ContentLayout
  title="Browse Tags | Blog | Timothy Pidashev"
  description="Browse blog posts by tag."
>
  <BlogHeader client:load />
  <TagList posts={posts} client:load />
</ContentLayout>
