Back to Demo

Sample Episode

This demonstrates the same polymorphic comment system working on podcast episodes. Notice how the identical component handles different entity types seamlessly.

Entity Type: EPISODE
Entity ID: cmd8necsz0007rs5klikruv1p
Episode Comments

The exact same comment system from the article page, now working on episodes. This showcases the true power of polymorphic design - one component, multiple contexts.

Polymorphic Comparison

Article Comments

<Comments 
  entity="ARTICLE" 
  entityId={article.id} 
/>

Same component, different entity type

Episode Comments

<Comments 
  entity="EPISODE" 
  entityId={episode.id} 
/>

Identical functionality, different context

Key Benefits:

  • Reusable component across all entity types
  • Consistent user experience
  • Easy to maintain and extend
  • Type-safe with TypeScript
Database Schema
// Polymorphic relationship in Prisma
model Comment {
  id        String        @id @default(cuid())
  entity    CommentEntity // ARTICLE, EPISODE, etc.
  entityId  String        // ID of the specific entity
  userId    String
  text      String
  parentId  String?       // For threaded replies
  
  // Relations
  user      User          @relation(fields: [userId], references: [id])
  parent    Comment?      @relation("CommentThread", fields: [parentId], references: [id])
  replies   Comment[]     @relation("CommentThread")
}

enum CommentEntity {
  ARTICLE
  EPISODE
  // Easy to extend with more types
}
System Capabilities

Universal Integration

Works with any entity type
Two props integration
No code duplication

Advanced Features

Server-side rendering
Real-time updates
User permissions