diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/BlogPosts.astro | 4 | ||||
| -rw-r--r-- | src/components/PostHeader.astro | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/components/BlogPosts.astro b/src/components/BlogPosts.astro index 54b7529..73f9b5c 100644 --- a/src/components/BlogPosts.astro +++ b/src/components/BlogPosts.astro @@ -1,6 +1,6 @@ --- import { getCollection } from 'astro:content'; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Card, CardContent, CardDescription, CardHeader } from "@/components/ui/card"; // Fetch all blog posts from the content collection const posts = await getCollection('blog'); @@ -18,7 +18,7 @@ const sortedPosts = posts.sort((a, b) => <a href={`/posts/${post.id}`} class="block hover:opacity-80 transition-opacity"> <Card> <CardHeader> - <CardTitle>{post.data.title}</CardTitle> + <h2 class="font-heading text-sm font-medium" transition:name={`post-title-${post.id}`}>{post.data.title}</h2> <CardDescription>{post.data.description}</CardDescription> </CardHeader> <CardContent> diff --git a/src/components/PostHeader.astro b/src/components/PostHeader.astro new file mode 100644 index 0000000..1845ec1 --- /dev/null +++ b/src/components/PostHeader.astro @@ -0,0 +1,29 @@ +--- +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; +--- + +<Card className="w-full"> + <CardHeader> + <div class="flex flex-wrap gap-2"> + <Badge variant="secondary">{author}</Badge> + <Badge variant="outline">{publishDate.toLocaleDateString()}</Badge> + </div> + <h1 class="font-heading text-xl font-medium md:text-2xl" transition:name={`post-title-${slug}`}>{title}</h1> + <CardDescription>{description}</CardDescription> + </CardHeader> + <CardContent> + <Separator /> + </CardContent> +</Card> |
