From 8e32f214626c8f9351de44df27339dca1d2b36d2 Mon Sep 17 00:00:00 2001 From: Timothy Pidashev Date: Tue, 14 Jan 2025 14:23:29 -0800 Subject: [PATCH] Update date format in blog slug --- src/src/pages/blog/[...slug].astro | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/src/pages/blog/[...slug].astro b/src/src/pages/blog/[...slug].astro index 3974c33..3d391a6 100644 --- a/src/src/pages/blog/[...slug].astro +++ b/src/src/pages/blog/[...slug].astro @@ -8,17 +8,29 @@ import { blogWebsite } from "@/lib/structuredData"; interface Props { post: CollectionEntry<"blog">; } + export async function getStaticPaths() { const posts = await getCollection("blog"); return posts.map((post) => ({ 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 { Content } = await post.render(); const articleStructuredData = getArticleSchema(post); - + const breadcrumbsStructuredData = { "@context": "https://schema.org", "@type": "BreadcrumbList", @@ -37,6 +49,7 @@ const breadcrumbsStructuredData = { }, ], }; + const jsonLd = { "@context": "https://schema.org", "@graph": [articleStructuredData, breadcrumbsStructuredData, blogWebsite],