to-html icon indicating copy to clipboard operation
to-html copied to clipboard

Need help in converting custom block into html

Open mostlycloudysky opened this issue 3 years ago • 0 comments

Hi Team,

I have been trying to convert the sanity webhook event data (which is portable text into html). However, i have a custom code block and would like to add it to the serializer. What would be the proper way to do it ? any example is really helpful, this is the last part of the webhook data that i stuck with and i am processing it on the server side.

      {
         "_key":"cae3d7fa8a0d",
         "_type":"codeBlock",
         "code":"<PortableText\n  className='prose mx-auto mt-8'\n  content={content}\n  projectId={process.env.PROJECT_ID}\n  dataset={process.env.DATASET}\n  serializers={{\n    code: props => {\n      // console.log('Testing', props)\n      return <pre>{props.children}</pre>\n    },\n    codeBlock: props => {\n      return <CodeBlock code={props.code} language={props.language} />\n    },\n  }}\n/>",
         "language":"html"
      },

mostlycloudysky avatar Jan 18 '23 01:01 mostlycloudysky