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

60 lines
1.2 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-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 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;
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
---
<style lang="scss">
@import "../../scss/_variables.scss";
2024-10-02 23:04:27 +00:00
p {
opacity: 0.5;
}
</style>
2024-10-02 23:04:27 +00:00
<Layout description={post.data.description} title={post.data.title}>
<article>
2024-10-02 23:04:27 +00:00
<section>
<p>
<small>
Posted
2024-10-02 23:04:27 +00:00
<time datetime={post.data.pubDate.toISOString()}>{formattedDate}</time>
by&nbsp;{post.data.author}
<span>&nbsp;•&nbsp;</span>
<span>{remarkPluginFrontmatter.minutesRead}</span>
</small>
</p>
</section>
<section>
<h1>{post.data.title}</h1>
</section>
<section>
<Content />
</section>
<section>
<Comments />
</section>
</article>
2024-09-04 21:16:37 +00:00
</Layout>