Skip to content

Need help in converting custom block into html #4

@mostlycloudysky

Description

@mostlycloudysky

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"
      },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions