import { notFound } from "next/navigation"; import { getRepository, getRepoFileTree, getRepoFile } from "@/actions/repositories"; import { FileTree } from "@/components/file-tree"; import { CodeViewer } from "@/components/code-viewer"; import { CloneUrl } from "@/components/clone-url"; import { Badge } from "@/components/ui/badge"; import { GitBranch, Lock, Globe, FileCode } from "lucide-react"; import Link from "next/link"; import { getPublicServerUrl } from "@/lib/utils"; export default async function RepoPage({ params }: { params: Promise<{ username: string; repo: string }> }) { const { username, repo: repoName } = await params; const repo = await getRepository(username, repoName); if (!repo) { notFound(); } const fileTree = await getRepoFileTree(username, repoName, repo.defaultBranch); const readmeFile = fileTree?.files.find((f) => f.name.toLowerCase() === "readme.md" && f.type === "blob"); let readmeContent = null; if (readmeFile) { const file = await getRepoFile(username, repoName, repo.defaultBranch, readmeFile.name); readmeContent = file?.content; } return (
{username} /
{repo.name}
{repo.visibility === "private" ? ( <> Private ) : ( <> Public )}
{repo.description &&

{repo.description}

}
{repo.defaultBranch}
{fileTree?.isEmpty ? ( ) : ( )}
{readmeContent && (
README.md
)}
); } function EmptyRepoGuide({ username, repoName }: { username: string; repoName: string }) { const cloneUrl = `${getPublicServerUrl()}/api/git/${username}/${repoName}.git`; return (

This repository is empty

Get started by cloning or pushing to this repository.

Create a new repository on the command line

            {`echo "# ${repoName}" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin ${cloneUrl}
git push -u origin main`}
          

Push an existing repository from the command line

            {`git remote add origin ${cloneUrl}
git branch -M main
git push -u origin main`}
          
); }