// src/components/lexical/Render.tsx
import { Fragment, type ReactNode } from 'react'
import { Callout } from './Callout'
import { LinkPreviewCard } from './LinkPreviewCard'
import { PostImage } from './PostImage'
import { anchorFor } from '@/lib/lexical-headings'
import { mediaUrl } from '@/lib/media-url'
type Node = { type: string; [key: string]: any }
function renderChildren(children: Node[] | undefined): ReactNode {
return (children ?? []).map((c, i) => {el}
return el
}
function renderNode(node: Node): ReactNode {
switch (node.type) {
case 'text':
return renderText(node)
case 'paragraph':
return
{renderChildren(node.children)}
case 'heading': { const Tag = (node.tag as 'h2' | 'h3' | 'h4' | 'h5' | 'h6') ?? 'h2' const id = anchorFor(node as { children?: Array<{ type: string; text?: string }> }) return{renderChildren(node.children)}case 'horizontalrule': return
{f.code}
)
}
return null
}
default:
return null
}
}
export function Render({ value }: { value?: { root: { children: Node[] } } | null }) {
if (!value?.root?.children) return null
return <>{renderChildren(value.root.children as Node[])}>
}