-
Notifications
You must be signed in to change notification settings - Fork 5
Providing serializer for custom blocks #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Currently sourcebit-source-sanity can only transform basic rich-text stuff. |
Yes, exactly. Here's an excerpt from my schema: {
title: "Content",
name: "content",
type: "array",
of: [
{
type: 'block'
},
{
type: 'image',
fields: [
{
type: 'text',
name: 'alt',
title: 'Alternative text',
options: {
isHighlighted: true
}
}
]
},
{
name: "copiable_snippet",
type: "object",
title: "Copiable Snippet",
fields: [
{
name: "text",
type: "text",
title: "Text"
}
]
}
]
} What's your opinion on providing support for custom blocks in sourcebit-source-sanity? From my perspective, being able to pass custom serializer as a plugin option would be the best scenario. Could be something like that: module.exports = {
plugins: [
{
module: require("sourcebit-source-sanity"),
options: {
dataset: "production",
projectId: "123456",
richTextOutputFormat: 'html',
serializers: {
html: {
copiable_snippet: ({ node }) => {
return `<div class="snippet">${node.text}</div>`
}
},
markdown: {
copiable_snippet: ({ node }) => {
return `{{< snippet >}}${node.text}{{< /snippet >}}`
}
}
}
}
}
]
} |
@dmgawel yep, passing serializers like this makes sense. module.exports = {
plugins: [
{
module: require('sourcebit-source-sanity'),
options: {
accessToken: process.env['SANITY_ACCESS_TOKEN'],
spaceId: '...',
dataset: 'production',
richTextOutputFormat: 'none'
}
},
(data) => {
updatedData = manipulateRichText(data);
return {
data: updatedData
}
}
]
}; |
When trying to fetch content with custom block type (e.g.
copiable_snippet
), sourcebit fails with a following error: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?
The text was updated successfully, but these errors were encountered: