0
mirror of https://github.com/valentineus/popov.link.git synced 2025-07-03 08:00:26 +03:00
Files
popov.link/src/pages/blog/[...slug].astro

59 lines
1.4 KiB
Plaintext
Raw Normal View History

2024-09-04 21:16:37 +00:00
---
import { type CollectionEntry, getCollection } from "astro:content";
2024-09-06 08:36:02 +00:00
import Comments from "../../components/Comments.astro";
2024-09-06 08:21:27 +00:00
import Layout from "../../layouts/PageLayout.astro";
import Pagination from "../../components/PostPagination.astro";
2024-09-04 21:16:37 +00:00
export async function getStaticPaths() {
const posts = await getCollection("blog");
const total = posts.length;
return posts.map((post, index) => ({
2024-09-04 21:16:37 +00:00
params: { slug: post.slug },
props: {
post,
prevPost: index + 1 === total ? null : posts[index + 1],
nextPost: index === 0 ? null : posts[index - 1],
},
2024-09-04 21:16:37 +00:00
}));
}
type Props = CollectionEntry<"blog">;
const { post, prevPost, nextPost } = Astro.props;
2024-09-06 08:21:27 +00:00
const { Content, remarkPluginFrontmatter } = await post.render();
2024-09-04 21:16:37 +00:00
---
2024-09-06 08:21:27 +00:00
<style>
.header {
text-align: center;
}
</style>
2024-09-11 22:03:55 +00:00
<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>
<Pagination prevPost={prevPost} nextPost={nextPost} />
</section>
<section>
<Comments />
</section>
</article>
2024-09-04 21:16:37 +00:00
</Layout>