From 45720f99bbb05939e521d692cc5119c174af78c9 Mon Sep 17 00:00:00 2001 From: IwanIDev Date: Sun, 22 Mar 2026 13:34:54 +0000 Subject: feat: add date formatting for publish dates in BlogPosts and PostHeader components --- src/components/BlogPosts.astro | 8 +++++++- src/components/PostHeader.astro | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/BlogPosts.astro b/src/components/BlogPosts.astro index 73f9b5c..9101e38 100644 --- a/src/components/BlogPosts.astro +++ b/src/components/BlogPosts.astro @@ -9,6 +9,12 @@ const posts = await getCollection('blog'); const sortedPosts = posts.sort((a, b) => new Date(b.data.publishDate).getTime() - new Date(a.data.publishDate).getTime() ); + +const dateFormatter = new Intl.DateTimeFormat('en-GB', { + day: '2-digit', + month: 'long', + year: 'numeric', +}); ---
@@ -23,7 +29,7 @@ const sortedPosts = posts.sort((a, b) =>
- {post.data.publishDate.toLocaleDateString()} + {dateFormatter.format(post.data.publishDate)} by {post.data.author}
diff --git a/src/components/PostHeader.astro b/src/components/PostHeader.astro index 1845ec1..cea0965 100644 --- a/src/components/PostHeader.astro +++ b/src/components/PostHeader.astro @@ -12,13 +12,19 @@ interface Props { } const { title, slug, description, author, publishDate } = Astro.props as Props; + +const dateFormatter = new Intl.DateTimeFormat('en-GB', { + day: '2-digit', + month: 'long', + year: 'numeric', +}); ---
{author} - {publishDate.toLocaleDateString()} + {dateFormatter.format(publishDate)}

{title}

{description} -- cgit