'use client' import { getFaviconUrl } from '@thedaviddias/utils/get-favicon-url' import { Globe } from 'lucide-react' import { useState } from 'react' interface FaviconProps { website: string fallbackIcon?: React.ComponentType<{ className?: string }> className?: string title?: string } /** * Displays a favicon with loading state and error handling * @param props - The component props * @returns React component that displays favicon or fallback icon */ export function Favicon({ website, fallbackIcon: FallbackIcon = Globe, className = 'h-4 w-4', title }: FaviconProps) { const [imageError, setImageError] = useState(false) const [imageLoading, setImageLoading] = useState(true) /** * Handles image load success */ const handleImageLoad = () => { setImageLoading(false) } /** * Handles image load error */ const handleImageError = () => { setImageError(true) setImageLoading(false) } // Extract size from className or use default const sizeMatch = className.match(/[hw]-(\d+)/) const size = sizeMatch ? Number.parseInt(sizeMatch[1], 10) * 4 : 16 // Convert Tailwind units to pixels if (imageError || !website) { return (