popov.link/src/pages/blog/[...slug].astro
Valentin Popov 4ba339984d
All checks were successful
Test / test (push) Successful in 38s
Test / test (pull_request) Successful in 36s
Updated the main page and page structures
2024-09-12 13:11:16 +00:00

48 lines
1.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
import { type CollectionEntry, getCollection } from "astro:content";
import Comments from "../../components/Comments.astro";
import Layout from "../../layouts/PageLayout.astro";
export async function getStaticPaths() {
const posts = await getCollection("blog");
return posts.map((post) => ({
params: { slug: post.slug },
props: post,
}));
}
type Props = CollectionEntry<"blog">;
const post = Astro.props;
const { Content, remarkPluginFrontmatter } = await post.render();
---
<style>
.header {
text-align: center;
}
</style>
<Layout title={post.data.title} description={post.data.description}>
<article>
<section class="header">
<h1>{post.data.title}</h1>
<p>
<small>
Posted
<time datetime={post.data.pubDate.toISOString()}>{post.data.pubDate.toDateString()}</time>
&nbsp;by&nbsp;{post.data.author}&nbsp;
<strong>{remarkPluginFrontmatter.minutesRead}</strong>
</small>
</p>
</section>
<section>
<Content />
</section>
<section>
<Comments />
</section>
</article>
</Layout>