---
import { getCollection, render } from "astro:content";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";

dayjs.extend(utc);

import MarkdownPostLayout from "../../layouts/MarkdownPostLayout.astro";

export async function getStaticPaths() {
	const posts = await getCollection("blog");
	return posts.map((post) => ({
		params: { slug: post.id },
		props: { post },
	}));
}

const { post } = Astro.props;
const { Content, remarkPluginFrontmatter } = await render(post);

const lastModified = dayjs(remarkPluginFrontmatter.lastModified)
  .utc()
  .format("HH:mm:ss DD MMMM YYYY UTC");
---
<MarkdownPostLayout frontmatter={post.data} lastModified={lastModified}>
  <Content />
</MarkdownPostLayout>