summaryrefslogtreecommitdiff
path: root/src/components/BlogPosts.astro
diff options
context:
space:
mode:
authorIwanIDev <iwan@iwani.dev>2026-03-22 13:34:54 +0000
committerIwanIDev <iwan@iwani.dev>2026-03-22 13:34:54 +0000
commit45720f99bbb05939e521d692cc5119c174af78c9 (patch)
tree8da6487decb40886fd77b7ca07fb734eccff5163 /src/components/BlogPosts.astro
parentece957eb3d306e10914839ab8a6794447c17fc29 (diff)
feat: add date formatting for publish dates in BlogPosts and PostHeader components
Diffstat (limited to 'src/components/BlogPosts.astro')
-rw-r--r--src/components/BlogPosts.astro8
1 files changed, 7 insertions, 1 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',
+});
---
<div class="w-full max-w-2xl mx-auto p-4">
@@ -23,7 +29,7 @@ const sortedPosts = posts.sort((a, b) =>
</CardHeader>
<CardContent>
<div class="flex justify-between text-sm text-gray-500">
- <span>{post.data.publishDate.toLocaleDateString()}</span>
+ <span>{dateFormatter.format(post.data.publishDate)}</span>
<span>by {post.data.author}</span>
</div>
</CardContent>