Update date format in blog slug

This commit is contained in:
Timothy Pidashev
2025-01-14 14:23:29 -08:00
parent de871e775e
commit 8e32f21462

View File

@@ -8,13 +8,25 @@ import { blogWebsite } from "@/lib/structuredData";
interface Props { interface Props {
post: CollectionEntry<"blog">; post: CollectionEntry<"blog">;
} }
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getCollection("blog"); const posts = await getCollection("blog");
return posts.map((post) => ({ return posts.map((post) => ({
params: { slug: post.slug }, params: { slug: post.slug },
props: post, props: {
...post,
data: {
...post.data,
date: new Date(post.data.date).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric"
})
}
},
})); }));
} }
const post = Astro.props; const post = Astro.props;
const { Content } = await post.render(); const { Content } = await post.render();
const articleStructuredData = getArticleSchema(post); const articleStructuredData = getArticleSchema(post);
@@ -37,6 +49,7 @@ const breadcrumbsStructuredData = {
}, },
], ],
}; };
const jsonLd = { const jsonLd = {
"@context": "https://schema.org", "@context": "https://schema.org",
"@graph": [articleStructuredData, breadcrumbsStructuredData, blogWebsite], "@graph": [articleStructuredData, breadcrumbsStructuredData, blogWebsite],