import React from 'react' export default function ThreadRow({ thread, isFirst = false }) { const id = thread?.topic_id ?? thread?.id ?? 0 const title = thread?.topic ?? thread?.title ?? 'Untitled' const slug = thread?.slug ?? slugify(title) const excerpt = thread?.discuss ?? '' const posts = thread?.num_posts ?? 0 const author = thread?.uname ?? 'Unknown' const lastUpdate = thread?.last_update ?? thread?.post_date const isPinned = thread?.is_pinned ?? false const href = `/forum/thread/${id}-${slug}` return ( {/* Icon */}
{isPinned ? ( ) : ( )}
{/* Content */}

{title}

{isPinned && ( Pinned )}
{excerpt && (

{stripHtml(excerpt).slice(0, 180)}

)}
{author} {posts} {posts === 1 ? 'reply' : 'replies'} {lastUpdate && ( {formatDate(lastUpdate)} )}
{/* Reply count badge */}
{posts}
) } function slugify(text) { return (text ?? '') .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)/g, '') .slice(0, 80) } function stripHtml(html) { if (typeof document !== 'undefined') { const div = document.createElement('div') div.innerHTML = html return div.textContent || div.innerText || '' } return html.replace(/<[^>]*>/g, '') } function formatDate(dateStr) { try { const d = new Date(dateStr) return d.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' }) + ' ' + d.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' }) } catch { return '-' } }