0
mirror of https://github.com/valentineus/popov.link.git synced 2025-07-03 16:10:26 +03:00
Files
popov.link/src/pages/blog/[...slug].astro
Valentin Popov 0473060773 feat: add configuration and default image for blog posts
- Introduced a new configuration file to centralize author information and default image settings for blog posts.
- Added a default image path in the blog post configuration for improved content presentation.
- Updated blog post schema to utilize the new configuration for author details, enhancing structured data representation.
2025-06-14 12:08:48 +00:00

79 lines
1.7 KiB
Plaintext

---
import { type CollectionEntry, getCollection } from "astro:content";
import Comments from "../../components/Comments.astro";
import Layout from "../../layouts/BaseLayout.astro";
import blogPostSchema from "../../utils/schemas/blogPostSchema";
import dayjs from "dayjs";
type Props = CollectionEntry<"blog">;
export async function getStaticPaths() {
const posts = await getCollection("blog", ({ data }) => {
return data.draft !== true;
});
return posts.map((post) => ({
params: { slug: post.slug },
props: post,
}));
}
const post = Astro.props;
const { Content, remarkPluginFrontmatter } = await post.render();
const description = post.data.description;
const isBasedOn = post.data.basedOn;
const lang = post.data.lang;
const slug = post.slug;
const title = post.data.title;
const dateModified = post.data.dateModified?.toISOString();
const datePublished = post.data.datePublished.toISOString();
const formattedDate = dayjs(post.data.datePublished.toString()).format("MMMM DD, YYYY");
const schema = blogPostSchema({
siteUrl: new URL("/", Astro.site).toString(),
title,
description,
slug,
datePublished,
dateModified,
lang,
isBasedOn,
});
---
<style lang="scss">
@use "../../scss/variables" as *;
p {
opacity: 0.5;
}
</style>
<Layout title={title} description={description} lang={lang} schema={schema}>
<article>
<header>
<h1>{title}</h1>
<p>
<small>
Posted
<time datetime={datePublished} lang="en">{formattedDate}</time>
<span>&nbsp;•&nbsp;</span>
<span>{remarkPluginFrontmatter.minutesRead}</span>
</small>
</p>
</header>
<section>
<Content />
</section>
<section>
<Comments />
</section>
</article>
</Layout>