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-12 16:36:57 +00:00
|
|
|
import Layout from "../../layouts/BaseLayout.astro";
|
2024-10-02 23:04:27 +00:00
|
|
|
import dayjs from "dayjs";
|
2024-09-04 21:16:37 +00:00
|
|
|
|
2024-09-12 22:57:55 +00:00
|
|
|
type Props = CollectionEntry<"blog">;
|
|
|
|
|
2024-09-04 21:16:37 +00:00
|
|
|
export async function getStaticPaths() {
|
2024-10-02 23:04:27 +00:00
|
|
|
const posts = await getCollection("blog", ({ data }) => {
|
|
|
|
return data.draft !== true;
|
|
|
|
});
|
2024-09-12 14:06:44 +00:00
|
|
|
|
2024-09-12 16:36:57 +00:00
|
|
|
return posts.map((post) => ({
|
2024-09-04 21:16:37 +00:00
|
|
|
params: { slug: post.slug },
|
2024-09-12 16:36:57 +00:00
|
|
|
props: post,
|
2024-09-04 21:16:37 +00:00
|
|
|
}));
|
|
|
|
}
|
2024-09-12 16:36:57 +00:00
|
|
|
|
|
|
|
const post = Astro.props;
|
2024-10-24 19:50:34 +00:00
|
|
|
const { Content, remarkPluginFrontmatter } = await post.render();
|
2024-10-02 23:04:27 +00:00
|
|
|
const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY");
|
2024-09-04 21:16:37 +00:00
|
|
|
---
|
|
|
|
|
2024-10-24 19:50:34 +00:00
|
|
|
<style lang="scss">
|
|
|
|
@import "../../scss/_variables.scss";
|
2024-10-02 23:04:27 +00:00
|
|
|
|
2024-10-24 19:50:34 +00:00
|
|
|
p {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
</style>
|
2024-10-02 23:04:27 +00:00
|
|
|
|
2024-10-24 19:50:34 +00:00
|
|
|
<Layout description={post.data.description} title={post.data.title}>
|
|
|
|
<article>
|
2024-10-02 23:04:27 +00:00
|
|
|
<section>
|
2024-09-12 13:11:16 +00:00
|
|
|
<p>
|
|
|
|
<small>
|
|
|
|
Posted
|
2024-10-02 23:04:27 +00:00
|
|
|
<time datetime={post.data.pubDate.toISOString()}>{formattedDate}</time>
|
|
|
|
by {post.data.author}
|
2024-10-24 19:50:34 +00:00
|
|
|
<span> • </span>
|
|
|
|
<span>{remarkPluginFrontmatter.minutesRead}</span>
|
2024-09-12 13:11:16 +00:00
|
|
|
</small>
|
|
|
|
</p>
|
|
|
|
</section>
|
|
|
|
|
2024-10-24 19:50:34 +00:00
|
|
|
<section>
|
|
|
|
<h1>{post.data.title}</h1>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<Content />
|
|
|
|
</section>
|
|
|
|
|
2024-09-12 13:11:16 +00:00
|
|
|
<section>
|
|
|
|
<Comments />
|
|
|
|
</section>
|
|
|
|
</article>
|
2024-09-04 21:16:37 +00:00
|
|
|
</Layout>
|