| 1 | import { BookMarked } from "lucide-react"; |
| 2 | import { CursorPagination } |
| 3 | import { RepositoryCard } |
| 4 | import { |
| 5 | Empty, |
| 6 | EmptyDescription, |
| 7 | EmptyHeader, |
| 8 | EmptyMedia, |
| 9 | EmptyTitle, |
| 10 | } from "@/components/ui/empty"; |
| 11 | import { createServerClient } |
| 12 | |
| 13 | const PAGE_SIZE = 20 |
| 14 | |
| 15 | export async function RepositoryResults |
| 16 | query, |
| 17 | cursor, |
| 18 | }: { |
| 19 | query: string |
| 20 | cursor?: string |
| 21 | }) { |
| 22 | const client = |
| 23 | const { data |
| 24 | params: { query: { |
| 25 | }); |
| 26 | if (!data) |
| 27 | |
| 28 | return ( |
| 29 | <> |
| 30 | {data.repositories.length |
| 31 | <div className="flex flex-col border-t |
| 32 | {data.repositories.map |
| 33 | <RepositoryCard |
| 34 | key={repository.id |
| 35 | showOwner |
| 36 | repository={{ ... |
| 37 | /> |
| 38 | ))} |
| 39 | </div> |
| 40 | ) : ( |
| 41 | <Empty className=" |
| 42 | <EmptyHeader> |
| 43 | <EmptyMedia variant=" |
| 44 | <BookMarked /> |
| 45 | </EmptyMedia> |
| 46 | <EmptyTitle>No repositories found</EmptyTitle |
| 47 | <EmptyDescription> |
| 48 | {query |
| 49 | ? `No public repository has “${query} |
| 50 | : "There are no public repositories yet."} |
| 51 | </EmptyDescription> |
| 52 | </EmptyHeader> |
| 53 | </Empty> |
| 54 | )} |
| 55 | |
| 56 | <CursorPagination |
| 57 | pathname="/search" |
| 58 | params={{ q: |
| 59 | cursor={cursor} |
| 60 | nextCursor={data.nextCursor |
| 61 | /> |
| 62 | </> |
| 63 | ); |
| 64 | } |