import React from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { GitBranch } from 'lucide-react'; import type { Repository } from '@/hooks/useUserRepositories'; import { useAuthor } from '@/hooks/useAuthor'; import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'; import { genUserName } from '@/lib/genUserName'; import { useNavigate } from 'react-router-dom'; import { nip19 } from 'nostr-tools'; interface RepositoryCardProps { repo: Repository; } export function RepositoryCard({ repo }: RepositoryCardProps) { const { data: authorData } = useAuthor(repo.pubkey); const navigate = useNavigate(); const displayName = authorData?.metadata?.name || genUserName(repo.pubkey); const profileImage = authorData?.metadata?.picture; // Construct Nostr clone URL const nostrCloneUrl = `nostr://${nip19.npubEncode(repo.pubkey)}/${repo.repoId}`; const handleClone = () => { // Navigate to clone page with Nostr URL parameter navigate(`/clone?url=${encodeURIComponent(nostrCloneUrl)}`); }; return ( {/* Header with name and author */}

{repo.name}

{profileImage && ( )} {displayName.slice(0, 2).toUpperCase()} {displayName}
{/* Description */} {repo.description && (

{repo.description}

)} {/* Tags */} {repo.repoTags.length > 0 && (
{repo.repoTags.slice(0, 3).map((tag, index) => ( {tag} ))} {repo.repoTags.length > 3 && ( +{repo.repoTags.length - 3} )}
)} {/* Personal fork badge */} {repo.isPersonalFork && (
Personal Fork
)} {/* Actions */}
); }