import { nodesToHtml } from "./utils"

import styles from "./jsontohtml.module.css"

import type { JsonToHtmlProps } from "@/types/transitionTypes/jsontohtml"

export default function JsonToHtml({
  embeds,
  nodes,
  renderOptions = {},
}: JsonToHtmlProps) {
  if (!Array.isArray(nodes) || !nodes.length) {
    return null
  }
  return (
    <section className={styles.container}>
      {nodesToHtml(nodes, embeds, renderOptions).filter(Boolean)}
    </section>
  )
}
