'use client'; import { useState, useEffect } from 'react'; import quotes from '@/public/quotes.json'; interface Quote { text: string; author?: string; link?: string; } function getDayOfYear(): number { const now = new Date(); const start = new Date(now.getFullYear(), 0, 0); const diff = now.getTime() - start.getTime(); return Math.floor(diff / (1000 * 60 * 60 * 24)); } export default function QuoteOfTheDay() { const [quote, setQuote] = useState(null); useEffect(() => { const index = getDayOfYear() % quotes.length; setQuote(quotes[index] as Quote); }, []); if (!quote) { return

 

; } const content = quote.author ? ( <> “{quote.text}” — {quote.author} ) : ( {quote.text} ); const href = quote.link && !/^https?:\/\//.test(quote.link) ? `https://${quote.link}` : quote.link; const wrapper = href ? ( {content} ) : ( content ); return (

{wrapper}

); }