'use client' import * as React from 'react' import Link from 'next/link' import { Star, Share2, ExternalLink, Copy, Mail, MessageSquare } from 'lucide-react' import { Button } from '@/components/ui/button' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { toast } from 'sonner' interface ReadmeHeaderProps { metadata: { title: string description: string stars: number lastUpdated: string url: string } } export function ReadmeHeader({ metadata }: ReadmeHeaderProps) { const [isSticky, setIsSticky] = React.useState(false) React.useEffect(() => { const handleScroll = () => { setIsSticky(window.scrollY > 100) } window.addEventListener('scroll', handleScroll) return () => window.removeEventListener('scroll', handleScroll) }, []) const handleCopyLink = async () => { try { await navigator.clipboard.writeText(window.location.href) toast.success('Link copied to clipboard!') } catch (error) { toast.error('Failed to copy link') } } const handleShare = (type: 'twitter' | 'email' | 'reddit') => { const url = encodeURIComponent(window.location.href) const text = encodeURIComponent(`Check out ${metadata.title}: ${metadata.description}`) const shareUrls = { twitter: `https://twitter.com/intent/tweet?text=${text}&url=${url}`, email: `mailto:?subject=${encodeURIComponent(metadata.title)}&body=${text}%20${url}`, reddit: `https://reddit.com/submit?url=${url}&title=${encodeURIComponent(metadata.title)}`, } window.open(shareUrls[type], '_blank', 'noopener,noreferrer') } return (
{/* Left side */}

{metadata.title}

{metadata.description}

{/* Right side - Actions */}
{/* Stars */}
{metadata.stars.toLocaleString()}
{/* Share Button */} Copy Link handleShare('twitter')}> Share on Twitter handleShare('reddit')}> Share on Reddit handleShare('email')}> Share via Email {/* GitHub Link */}
{/* Last updated */}
Last updated: {new Date(metadata.lastUpdated).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric', })}
) }