import React from 'react' /** * Compact artwork card for embedding inside a PostCard. * Shows thumbnail, title and original author with attribution. */ export default function EmbeddedArtworkCard({ artwork }) { if (!artwork) return null const artUrl = `/art/${artwork.id}/${slugify(artwork.title)}` const authorUrl = `/@${artwork.author.username}` const handleCardClick = (e) => { // Don't navigate when clicking the author link if (e.defaultPrevented) return window.location.href = artUrl } const handleKeyDown = (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() window.location.href = artUrl } } return ( // Outer element is a div to avoid inside — navigation handled via onClick
{/* Thumbnail */}
{artwork.thumb_url ? ( {artwork.title} ) : (
)}
{/* Meta */}

{artwork.title}

e.stopPropagation()} className="text-xs text-slate-400 hover:text-sky-400 transition-colors mt-0.5 truncate" > by {artwork.author.name || `@${artwork.author.username}`} Artwork
) } function slugify(str) { return (str || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') }