<script lang="ts">
  import { resolve } from '$app/paths';
  import type { PageProps } from './$types';

  let { data }: PageProps = $props();
</script>

<div class="flex justify-center">
  <div class="max-w-2xl">
    <div class="font-genericmono">
      {#each Object.entries(data.posts) as [_filename, post]}
        <a
          href={resolve('/blog/[id=int]-[slug]', {
            id: post.metadata.id.toString(),
            slug: post.metadata.slug,
          })}
          class="text-red-400 transition-all afterunderline-red-400 hover:afterunderline-hoverstate hover:text-white"
          >link</a
        >
        -
        <a
          href={resolve('/blog/[id=int]', {
            id: post.metadata.id.toString(),
          })}
          class="text-red-400 transition-all afterunderline-red-400 hover:afterunderline-hoverstate hover:text-white"
          >short</a
        >
        {JSON.stringify(post.metadata, (k, v) =>
          v instanceof Date ? v.toISOString() : v,
        )}
      {/each}
    </div>
  </div>
</div>
