| 1 | import Link from "next/link"; |
| 2 | |
| 3 | import { FromNowHoverCard } |
| 4 | import { Badge } |
| 5 | import { cn } |
| 6 | |
| 7 | /** The fields of a repository every listing of them returns. */ |
| 8 | export type Repository |
| 9 | name: string |
| 10 | slug: string |
| 11 | owner: string |
| 12 | description?: string |
| 13 | visibility: "public |
| 14 | lastPushedAt: string |
| 15 | }; |
| 16 | |
| 17 | export function RepositoryCard({ |
| 18 | repository, |
| 19 | showOwner = false, |
| 20 | className, |
| 21 | }: { |
| 22 | repository: Repository |
| 23 | showOwner?: boolean |
| 24 | className?: string |
| 25 | }) { |
| 26 | const { name, |
| 27 | repository; |
| 28 | |
| 29 | return ( |
| 30 | <article |
| 31 | className={cn( |
| 32 | "flex flex-col gap-2 border-b py-4 last:border-b-0", |
| 33 | className, |
| 34 | )} |
| 35 | > |
| 36 | <div className="flex items-start justify-between gap-3 |
| 37 | <h3 className="min-w-0 text-base break-words |
| 38 | <Link |
| 39 | href={`/${owner |
| 40 | className="text-primary hover:underline" |
| 41 | > |
| 42 | {showOwner && <span |
| 43 | <span className="font-semibold |
| 44 | </Link> |
| 45 | </h3> |
| 46 | |
| 47 | <Badge variant=" |
| 48 | {visibility} |
| 49 | </Badge> |
| 50 | </div> |
| 51 | |
| 52 | {description && ( |
| 53 | <p className="line-clamp-2 text-sm text-muted-foreground |
| 54 | {description} |
| 55 | </p> |
| 56 | )} |
| 57 | |
| 58 | <div className="flex flex-wrap items-center gap-4 text-xs text-muted-foreground |
| 59 | <span> |
| 60 | Updated <FromNowHoverCard date={ |
| 61 | </span> |
| 62 | </div> |
| 63 | </article> |
| 64 | ); |
| 65 | } |