next.js/examples/cms-prepr/components/post-body.js
post-body.js16 lines490 B
import Image from "next/image";

export default function PostBody({ content }) {
  const renderedContent = content.map((item) => {
    if (item.__typename === "Text") {
      return <div dangerouslySetInnerHTML={{ __html: item.html }}></div>;
    } else if (item.__typename === "Image") {
      return <Image src={item.url} alt="image" width={1000} height={500} />;
    } else {
      return null;
    }
  });

  return <div className="max-w-2xl mx-auto article">{renderedContent}</div>;
}
Quest for Codev2.0.0
/
SIGN IN