import React, { useState } from "react"; import Markdown from "react-markdown"; import { Book } from "../types"; import { Sparkles, Calendar, ShoppingBag, Music, ExternalLink, Tag } from "lucide-react"; interface SpotlightSectionProps { book: Book; title?: string; subtitle?: string; accentColor: string; secondaryColor: string; cardBgColor: string; } export default function SpotlightSection({ book, title, subtitle, accentColor, secondaryColor, cardBgColor, }: SpotlightSectionProps) { const [showSpotify, setShowSpotify] = useState(false); // Helper to check if a release date is in the future const isFutureRelease = (): boolean => { if (!book.publishedYear) return false; const str = String(book.publishedYear).trim(); // Check if it's a 4-digit year like "2027" if (/^\d{4}$/.test(str)) { return parseInt(str) > new Date().getFullYear(); } // Check if it's a German date e.g. "15.10.2026" or "15.10.26" const germanDateMatch = str.match(/^(\d{1,2})\.(\d{1,2})\.(\d{2,4})$/); if (germanDateMatch) { let [, day, month, year] = germanDateMatch; if (year.length === 2) year = "20" + year; const parsedDate = new Date(parseInt(year), parseInt(month) - 1, parseInt(day)); return parsedDate > new Date(); } // Standard JS Date parse const parsed = Date.parse(str); if (!isNaN(parsed)) { return parsed > Date.now(); } return false; }; const isFuture = isFutureRelease(); const badgeText = book.spotlightBadge || (isFuture ? `Erscheint am ${book.publishedYear}` : "Neuerscheinung"); return (

{title || "Spotlight & Neuerscheinung"}

{subtitle || "Besonders hervorgehobenes Werk im Fokus"}

{/* Subtle Ambient Background Gradient */}
{/* Cover image column */}
{/* Details column */}