import { RichText } from './rich-text' import { Quote } from './quote' import { Media } from './media' import { Slider } from './slider' import type { IRichText } from './rich-text' import type { IQuote } from './quote' import type { IMedia } from './media' import type { ISlider } from './slider' // Union type of all block types export type Block = IRichText | IQuote | IMedia | ISlider interface BlockRendererProps { blocks: Array } /** * BlockRenderer - Renders dynamic content blocks from Strapi * * Usage: * ```tsx * * ``` */ export function BlockRenderer({ blocks }: Readonly) { if (!blocks || blocks.length === 0) return null const renderBlock = (block: Block) => { switch (block.__component) { case 'shared.rich-text': return case 'shared.quote': return case 'shared.media': return case 'shared.slider': return default: // Log unknown block types in development console.warn('Unknown block type:', (block as any).__component) return null } } return (
{blocks.map((block, index) => (
{renderBlock(block)}
))}
) }