| 1 | import { GitCommitHorizontal } from "lucide-react"; |
| 2 | import Link from "next/link |
| 3 | import { notFound } |
| 4 | |
| 5 | import { FileDiffs } |
| 6 | import { CommitVerificationBadge } |
| 7 | import { FromNowHoverCard } |
| 8 | import { createServerClient } |
| 9 | import { API_URL } |
| 10 | |
| 11 | export default async function |
| 12 | params, |
| 13 | }: PageProps< |
| 14 | const { username, |
| 15 | |
| 16 | const client = |
| 17 | |
| 18 | const commit = |
| 19 | "/api/repositories/{username}/{slug}/commits/{sha}", |
| 20 | { params: { path: |
| 21 | ); |
| 22 | |
| 23 | if (commit.response |
| 24 | if (!commit.data |
| 25 | |
| 26 | return ( |
| 27 | <div className="flex flex-col gap-4 |
| 28 | <div className="rounded-lg border |
| 29 | <div className="flex items-center gap-2 border-b bg-muted/40 px-4 py-2.5 text-sm |
| 30 | <GitCommitHorizontal className=" |
| 31 | <span className="truncate font-medium |
| 32 | <CommitVerificationBadge verification={ |
| 33 | <Link |
| 34 | href={`/${username |
| 35 | className="ml-auto shrink-0 text-xs text-muted-foreground hover:underline" |
| 36 | > |
| 37 | Browse files at {commit.data.sha |
| 38 | </Link> |
| 39 | </div> |
| 40 | |
| 41 | <div className="px-4 py-2.5 text-xs text-muted-foreground |
| 42 | {commit.data.authorName |
| 43 | <FromNowHoverCard date={ |
| 44 | {" · "} |
| 45 | {commit.data.files |
| 46 | {commit.data.files |
| 47 | </div> |
| 48 | |
| 49 | {commit.data.body |
| 50 | <pre className="border-t px-4 py-2.5 text-xs whitespace-pre-wrap |
| 51 | {commit.data.body |
| 52 | </pre> |
| 53 | )} |
| 54 | </div> |
| 55 | |
| 56 | {commit.data.files |
| 57 | <p className="rounded-lg border border-dashed py-16 text-center text-sm text-muted-foreground |
| 58 | This commit has no textual changes. |
| 59 | </p> |
| 60 | ) : ( |
| 61 | <FileDiffs |
| 62 | patchUrl={`${API_URL |
| 63 | files={commit.data |
| 64 | /> |
| 65 | )} |
| 66 | </div> |
| 67 | ); |
| 68 | } |