import Link from 'next/link'; import { ArrowUpRight, Calendar, Edit2, Trash2 } from 'lucide-react'; import { decodeHtmlEntities } from '@/lib/utils'; interface NewsCardProps { id: string; slug: string; titulo: string; resumen: string; tipo?: string; fecha: string; imagenUrl?: string | null; showCategory?: boolean; showFooterDate?: boolean; showFooterButton?: boolean; footerText?: string; isAdmin?: boolean; imageAspect?: string; } export const NewsCard = ({ id, slug, titulo: rawTitulo, resumen: rawResumen, tipo, fecha, imagenUrl, showCategory = false, showFooterDate = false, showFooterButton = false, footerText, isAdmin = false, imageAspect = 'aspect-video' }: NewsCardProps) => { const titulo = decodeHtmlEntities(rawTitulo); // Strip HTML tags safely for a plain text excerpt const plainTextResumen = (rawResumen || '').replace(/<[^>]*>?/gm, ' ').replace(/\s+/g, ' ').trim(); const resumen = decodeHtmlEntities(plainTextResumen); // Formatear fecha const fechaObj = new Date(fecha); const fechaFormateada = fechaObj.toLocaleDateString('es-ES', { day: '2-digit', month: 'short', year: 'numeric' }); return (
{/* Click Frontal */} Ver {titulo} {/* Admin Controls (Elevado en el stacking context) - Dynamic Island style */} {isAdmin && (
Editar
Eliminar
)} {/* Imagen Destacada */}
{imagenUrl ? ( <> {/* Blurred Background to fill empty spaces nicely */} {/* Main Image contained properly without crop */} {titulo} ) : (
Almeira Web
)} {/* Badge/Tag - Habilitable por prop */} {showCategory && (
{tipo?.toUpperCase() || 'NOTICIA'}
)}
{/* Contenido */}

{titulo}

{resumen}

{/* Footer del card */} {(showFooterDate || footerText) && (
{showFooterDate ? (
{fechaFormateada}
) : ( footerText || "" )}
{showFooterButton && footerText && (
)}
)}
); };