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";
|
2024-09-12 14:06:44 +00:00
|
|
|
|
import Pagination from "../../components/PostPagination.astro";
|
2024-09-04 21:16:37 +00:00
|
|
|
|
|
|
|
|
|
export async function getStaticPaths() {
|
|
|
|
|
const posts = await getCollection("blog");
|
2024-09-12 14:06:44 +00:00
|
|
|
|
const total = posts.length;
|
|
|
|
|
|
|
|
|
|
return posts.map((post, index) => ({
|
2024-09-04 21:16:37 +00:00
|
|
|
|
params: { slug: post.slug },
|
2024-09-12 14:06:44 +00:00
|
|
|
|
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">;
|
|
|
|
|
|
2024-09-12 14:06:44 +00:00
|
|
|
|
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}>
|
2024-09-12 13:11:16 +00:00
|
|
|
|
<article>
|
|
|
|
|
<section class="header">
|
|
|
|
|
<h1>{post.data.title}</h1>
|
|
|
|
|
<p>
|
|
|
|
|
<small>
|
|
|
|
|
Posted
|
|
|
|
|
<time datetime={post.data.pubDate.toISOString()}>{post.data.pubDate.toDateString()}</time>
|
|
|
|
|
by {post.data.author} ‐
|
|
|
|
|
<strong>{remarkPluginFrontmatter.minutesRead}</strong>
|
|
|
|
|
</small>
|
|
|
|
|
</p>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section>
|
|
|
|
|
<Content />
|
|
|
|
|
</section>
|
|
|
|
|
|
2024-09-12 14:06:44 +00:00
|
|
|
|
<section>
|
|
|
|
|
<Pagination prevPost={prevPost} nextPost={nextPost} />
|
|
|
|
|
</section>
|
|
|
|
|
|
2024-09-12 13:11:16 +00:00
|
|
|
|
<section>
|
|
|
|
|
<Comments />
|
|
|
|
|
</section>
|
|
|
|
|
</article>
|
2024-09-04 21:16:37 +00:00
|
|
|
|
</Layout>
|