<script lang="ts" module>
  export * from './Post';
</script>

<script lang="ts">
  import { parsePostMetadata, type Post } from './Post';

  let {
    post,
    filename,
  }: {
    post: Post;
    filename?: string;
  } = $props();

  let meta = $derived(parsePostMetadata(post.metadata));

  let PostComp = $derived(post.default);
</script>

<div class="flex justify-center">
  <div class="max-w-2xl w-full">
    <h1 class="font-space-grotesk text-5xl mt-8 mb-4">
      <span class="text-accent-primary select-none">:&nbsp;</span
      >{meta.title}<span class="text-accent-primary select-none">;</span>
    </h1>
    <p class="my-4 font-genericmono">
      ctime: {meta.created.toISOString().split('T')[0]}<span class="select-none"
        >&MediumSpace;▒&MediumSpace;</span
      >mtime: {meta.updated.toISOString().split('T')[0]}{#if filename}<span
          class="select-none">&MediumSpace;▒&MediumSpace;</span
        ><a
          href={encodeURI(
            `https://codeberg.org/dmpmem/tilde/src/branch/master/src/routes/blog/${filename}`,
          )}
          class="quicklink"
          target="_blank"
          rel="noopener noreferrer">src</a
        >{/if}
    </p>
    <article id="postmd">
      <PostComp />
    </article>
  </div>
</div>
