/** * TopicList - Paginated list of TopicCard components. * Renders topics with optional heading and empty state. * Separates pinned topics from regular topics with section headings. * @see specs/prd-web.md Section 4 (Topic Components) */ import type { Topic } from '@/lib/api/types' import { TopicCard } from './topic-card' interface TopicListProps { topics: Topic[] heading?: string } export function TopicList({ topics, heading }: TopicListProps) { const pinnedTopics = topics.filter((t) => t.isPinned) const regularTopics = topics.filter((t) => !t.isPinned) const hasPinned = pinnedTopics.length > 0 return (
{heading &&

{heading}

} {topics.length === 0 ? (

No topics yet. Be the first to start a discussion!

) : (
{hasPinned && ( <>

Pinned

{pinnedTopics.map((topic) => ( ))}

Topics

)} {regularTopics.map((topic) => ( ))}
)}
) }