import { Suspense } from "react"; import { notFound } from "next/navigation"; import { connection } from "next/server"; import { getRepoPageData, getRepoReadme, getRepoCommitCountCached } from "@/actions/repositories"; import { FileTree } from "@/components/file-tree"; import { CodeViewer } from "@/components/code-viewer"; import { CloneUrl } from "@/components/clone-url"; import { StarButton } from "@/components/star-button"; import { BranchSelector } from "@/components/branch-selector"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Lock, Globe, FileCode, Settings, GitCommit, GitBranch, Loader2 } from "lucide-react"; import Link from "next/link"; import { getPublicServerUrl } from "@/lib/utils"; async function CommitCount({ username, repoName, branch }: { username: string; repoName: string; branch: string }) { await connection(); const commitCount = await getRepoCommitCountCached(username, repoName); if (commitCount === 0) return null; return ( {commitCount} commits ); } async function ReadmeSection({ username, repoName, readmeOid }: { username: string; repoName: string; readmeOid: string }) { await connection(); const content = await getRepoReadme(username, repoName, readmeOid); if (!content) return null; return (
README.md
); } function ReadmeSkeleton() { return (
README.md
); } function CommitCountSkeleton() { return (
); } export default async function RepoPage({ params }: { params: Promise<{ username: string; repo: string }> }) { const { username, repo: repoName } = await params; const data = await getRepoPageData(username, repoName); if (!data) { notFound(); } const { repo, files, isEmpty, branches, readmeOid, isOwner } = data; return (
{username} /
{repo.name}
{repo.visibility === "private" ? ( <> Private ) : ( <> Public )}
{isOwner && ( )}
{repo.description &&

{repo.description}

}
}>
{isEmpty ? ( ) : ( )}
{readmeOid && ( }> )}
); } 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`}
          
); }