import { type EditorBlock, toObject } from "@wp-reactor/editorial"
import { Suspense } from "react"
import { blockRegistry } from "@/blocks"
interface ContentProps {
page?: {
editorBlocks?: EditorBlock[]
content?: string
uri?: string
}
blocks?: EditorBlock[]
}
export function Content({ page, blocks }: ContentProps) {
const list = page?.editorBlocks ?? blocks ?? []
const topLevel = list.filter((block) => !block.parentClientId)
return (
<>
{topLevel.map((block, index) => {
const key = `${block.name || "block"}-${block.clientId || index}`
if (blockRegistry.belongsToNamespace(block.name)) {
const Renderer = blockRegistry.get(block.name)
const attributes = toObject(block.attributes)
// Certains blocs sont `React.lazy` (cf. blocks.tsx) : le rendu doit
// vivre sous un `Suspense`. Le HTML est émis en SSR (streaming), le
// fallback `null` n'apparaît qu'en navigation client le temps du chunk.
return (