import type * as React from "react"
import type { SlateElement, SlateText } from "@/types"
function SlateRenderer({ nodes }: { nodes: SlateElement[] }) {
return (
{nodes.map((node, index) => (
))}
)
}
function SlateNode({ node }: { node: SlateElement }) {
const alignClass = node.align === "center" ? "text-center" : node.align === "right" ? "text-right" : "text-left"
switch (node.type) {
case "heading":
return (
{node.children.map((child, idx) => (
))}
)
case "bullet-list":
return (
{node.children.map((child, idx) => (
-
{child.text}
))}
)
case "paragraph":
default:
return (
{node.children.map((child, idx) => (
))}
)
}
}
function SlateLeaf({ leaf }: { leaf: SlateText }) {
let children: React.ReactNode = leaf.text
if (leaf.bold) {
children = {children}
}
if (leaf.italic) {
children = {children}
}
if (leaf.code) {
children = {children}
}
return {children}
}
export { SlateRenderer }