Skip to content

Providing serializer for custom blocks #17

@dmgawel

Description

@dmgawel

When trying to fetch content with custom block type (e.g. copiable_snippet), sourcebit fails with a following error:

> sourcebit fetch
✖ An error occurred when processing the plugins: Unknown block type "copiable_snippet", please specify a serializer for it in the `serializers.types` prop.
Error: Unknown block type "copiable_snippet", please specify a serializer for it in the `serializers.types` prop
    at BlockSerializer (/Users/dawid/Projects/sanity/node_modules/@sanity/block-content-to-hyperscript/lib/serializers.js:23:13)
    at renderNode (/Users/dawid/Projects/sanity/node_modules/@sanity/block-content-to-hyperscript/lib/index.js:17:12)
    at serializeBlock (/Users/dawid/Projects/sanity/node_modules/@sanity/block-content-to-hyperscript/lib/blocksToNodes.js:88:12)
    at serializeNode (/Users/dawid/Projects/sanity/node_modules/@sanity/block-content-to-hyperscript/lib/blocksToNodes.js:55:12)
    at Array.map (<anonymous>)
    at blocksToNodes (/Users/dawid/Projects/sanity/node_modules/@sanity/block-content-to-hyperscript/lib/blocksToNodes.js:119:22)
    at blockContentToHyperscript (/Users/dawid/Projects/sanity/node_modules/@sanity/block-content-to-hyperscript/lib/index.js:34:10)
    at blocksToHtml (/Users/dawid/Projects/sanity/node_modules/@sanity/block-content-to-html/lib/blocksToHtml.js:7:18)
    at convertBlockToHTML (/Users/dawid/Projects/sanity/node_modules/sourcebit-source-sanity/lib/sanity-util.js:20:12)
    at normalizeValue (/Users/dawid/Projects/sanity/node_modules/sourcebit-source-sanity/lib/sanity-util.js:167:24)

Currently, it's not possible to provide serializer for custom blocks. Would it be possible to add support for such a case, for example as a plugin option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions