From e88144ab670e7585f998ce9d54236d5cc77d6bd4 Mon Sep 17 00:00:00 2001 From: IwanIDev Date: Fri, 27 Mar 2026 16:14:29 +0000 Subject: refactor: made the home page blog post cards and the blog post card header more consistent They are now the same component. I've renamed the component from PostHeader to BlogPostCard, which is more accurate now. --- src/components/BlogPostCard.astro | 34 ++++++++++++++++++++++++++++++++++ src/components/BlogPosts.astro | 21 +++++++++------------ src/components/PostHeader.astro | 35 ----------------------------------- 3 files changed, 43 insertions(+), 47 deletions(-) create mode 100644 src/components/BlogPostCard.astro delete mode 100644 src/components/PostHeader.astro diff --git a/src/components/BlogPostCard.astro b/src/components/BlogPostCard.astro new file mode 100644 index 0000000..875ddca --- /dev/null +++ b/src/components/BlogPostCard.astro @@ -0,0 +1,34 @@ +--- +import { Card, CardContent, CardDescription, CardHeader, CardFooter } from "@/components/ui/card"; +import { Badge } from "@/components/ui/badge"; +import { Separator } from "@/components/ui/separator"; + +interface Props { + title: string; + slug: string; + description: string; + author: string; + publishDate: Date; +} + +const { title, slug, description, author, publishDate } = Astro.props as Props; + +const dateFormatter = new Intl.DateTimeFormat('en-GB', { + day: '2-digit', + month: 'long', + year: 'numeric', +}); +--- + + + +

{title}

+ {description} +
+ +
+ {author} + {dateFormatter.format(publishDate)} +
+
+
diff --git a/src/components/BlogPosts.astro b/src/components/BlogPosts.astro index 48b94f0..87a75f4 100644 --- a/src/components/BlogPosts.astro +++ b/src/components/BlogPosts.astro @@ -1,6 +1,8 @@ --- import { getCollection } from 'astro:content'; import { Card, CardContent, CardDescription, CardHeader } from "@/components/ui/card"; +import { Badge } from "@/components/ui/badge"; +import PostHeader from "@/components/PostHeader.astro"; // Fetch all blog posts from the content collection const posts = await getCollection('blog'); @@ -22,18 +24,13 @@ const dateFormatter = new Intl.DateTimeFormat('en-GB', {
{sortedPosts.map((post) => ( - - -

{post.data.title}

- {post.data.description} -
- -
- {dateFormatter.format(post.data.publishDate)} - by {post.data.author} -
-
-
+
))}
diff --git a/src/components/PostHeader.astro b/src/components/PostHeader.astro deleted file mode 100644 index cea0965..0000000 --- a/src/components/PostHeader.astro +++ /dev/null @@ -1,35 +0,0 @@ ---- -import { Card, CardContent, CardDescription, CardHeader } from "@/components/ui/card"; -import { Badge } from "@/components/ui/badge"; -import { Separator } from "@/components/ui/separator"; - -interface Props { - title: string; - slug: string; - description: string; - author: string; - publishDate: Date; -} - -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} - {dateFormatter.format(publishDate)} -
-

{title}

- {description} -
- - - -
-- cgit