Blog Card

Disposition de carte pour afficher les apercus d'articles de blog. Installez Blog Card depuis le registre VLLNT UI avec la CLI shadcn.

Signaler un bug

Disposition de carte pour afficher les apercus d'articles de blog. Fait partie de la famille content dans VLLNT UI, il est publie comme entree de registre lisible par machine — copiez la source directement dans votre application avec la CLI shadcn et possedez-la, sans dependance d'execution a une bibliotheque de composants.

Apercu

Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.

Installation

Ajoutez Blog Card a votre projet avec la CLI shadcn. La source arrive dans votre code, prete a etre adaptee :

pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/blog-card.json

Source

import Link from "next/link"; import { Badge } from "../badge/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "../card/card"; type ContentCardPost = { date?: string; description: string; slug: string; tags?: string[]; title: string; updatedDate?: string; }; type ContentCardProps = { formatDate?: (date: string, lang: string) => string; getDictValue?: (dict: Record<string, unknown>, path: string) => string; href: string; lang?: string; post: ContentCardPost; readMoreLabel?: string; showBadge?: boolean; showDate?: boolean; showReadMore?: boolean; updatedLabel?: string; }; export function ContentCard({ formatDate, href, lang, post, readMoreLabel, showBadge = true, showDate = true, showReadMore = true, updatedLabel, }: ContentCardProps) { const shouldShowBadge = showBadge && post.tags && post.tags.length > 0; const shouldShowDate = showDate && post.date && formatDate && lang; const shouldShowUpdatedDate = showDate && post.updatedDate && formatDate && lang; const shouldShowHeaderMeta = shouldShowBadge || shouldShowDate || shouldShowUpdatedDate; return ( <Link className="block h-full" href={href}> <Card className="h-full flex flex-col hover:shadow-lg transition-shadow cursor-pointer"> <CardHeader> {shouldShowHeaderMeta ? ( <div className="flex items-center gap-2 mb-2"> {shouldShowBadge ? ( <Badge className="text-xs" variant="secondary"> {post.tags?.[0]} </Badge> ) : null} {shouldShowDate && post.date && lang ? ( <span className="text-xs text-muted-foreground"> {formatDate(post.date, lang)} </span> ) : null} {shouldShowUpdatedDate && post.updatedDate && lang ? ( <span className="text-xs text-muted-foreground"> {updatedLabel ? `${updatedLabel} ` : ""} {formatDate(post.updatedDate, lang)} </span> ) : null} </div> ) : null} <CardTitle className="text-lg line-clamp-2">{post.title}</CardTitle> <CardDescription className="line-clamp-3"> {post.description} </CardDescription> </CardHeader> {showReadMore && readMoreLabel ? ( <CardContent className="mt-auto"> <span className="inline-flex items-center gap-1 text-sm text-muted-foreground"> {readMoreLabel} <span className="text-sm"></span> </span> </CardContent> ) : null} </Card> </Link> ); } export function BlogCard(props: ContentCardProps) { return <ContentCard {...props} />; }

Stories

Explorez chaque variante et etat dans le Storybook interactif :

Apercu

Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.

Dependances

  • @vllnt/ui@^0.3.0