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";
|
2025-06-11 23:20:36 +00:00
|
|
|
import blogPostSchema from "../../utils/schemas/blogPostSchema";
|
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;
|
2025-06-11 17:20:43 +00:00
|
|
|
|
2024-10-24 19:50:34 +00:00
|
|
|
const { Content, remarkPluginFrontmatter } = await post.render();
|
2025-06-11 17:20:43 +00:00
|
|
|
|
2025-06-11 23:20:36 +00:00
|
|
|
const title = post.data.title;
|
2025-06-11 17:20:43 +00:00
|
|
|
const description = post.data.description;
|
2025-06-11 23:20:36 +00:00
|
|
|
const author = post.data.author;
|
2025-06-11 17:49:14 +00:00
|
|
|
const lang = post.data.lang;
|
2025-06-11 23:20:36 +00:00
|
|
|
|
|
|
|
const formattedData = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY");
|
|
|
|
const data = post.data.pubDate.toISOString();
|
|
|
|
|
|
|
|
const schema = blogPostSchema({
|
|
|
|
siteUrl: new URL("/", Astro.site).toString(),
|
|
|
|
title,
|
|
|
|
slug: post.slug,
|
|
|
|
datePublished: data,
|
|
|
|
author,
|
|
|
|
});
|
2024-09-04 21:16:37 +00:00
|
|
|
---
|
|
|
|
|
2024-10-24 19:50:34 +00:00
|
|
|
<style lang="scss">
|
2025-06-10 22:38:58 +04:00
|
|
|
@use "../../scss/variables" as *;
|
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
|
|
|
|
2025-06-11 23:20:36 +00:00
|
|
|
<Layout title={title} description={description} lang={lang} schema={schema}>
|
2024-10-24 19:50:34 +00:00
|
|
|
<article>
|
2025-06-10 13:44:56 +00:00
|
|
|
<section>
|
2025-06-11 23:20:36 +00:00
|
|
|
<h1>{title}</h1>
|
2025-06-10 13:44:56 +00:00
|
|
|
</section>
|
|
|
|
|
2024-10-02 23:04:27 +00:00
|
|
|
<section>
|
2024-09-12 13:11:16 +00:00
|
|
|
<p>
|
|
|
|
<small>
|
|
|
|
Posted
|
2025-06-11 23:20:36 +00:00
|
|
|
<time datetime={data} lang="en">{formattedData}</time>
|
|
|
|
by {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>
|
|
|
|
<Content />
|
|
|
|
</section>
|
|
|
|
|
2024-09-12 13:11:16 +00:00
|
|
|
<section>
|
|
|
|
<Comments />
|
|
|
|
</section>
|
|
|
|
</article>
|
2024-09-04 21:16:37 +00:00
|
|
|
</Layout>
|