Error with schema when used inside blockContent in Sanity Studio
Based on the error you're experiencing, the issue is that you're trying to use a standalone array schema as a custom block type within blockContent (Portable Text), but the schema structure isn't quite right for that purpose.
The error (value || []).some is not a function typically occurs when Sanity expects an object type but receives an array type definition directly. When you embed custom blocks in Portable Text, you need to define them as object types, not array types at the top level.
Here's how to fix your slideshow schema for use in blockContent:
export default {
name: "slideshow",
title: "Slideshow",
type: "object", // Changed from "array" to "object"
fields: [
{
name: "slides", // Wrap the array inside a field
title: "Slides",
type: "array",
of: [
{
type: "image",
fields: [
{
name: "caption",
type: "string",
title: "Caption",
options: {
isHighlighted: true,
},
},
],
},
],
},
],
preview: {
select: {
slides: "slides",
},
prepare({ slides }) {
return {
title: "Slideshow",
subtitle: `${slides?.length || 0} images`,
};
},
},
};Then in your blockContent definition, you can use it like this:
{
name: 'body',
type: 'array',
of: [
{type: 'block'}, // Standard rich text
{type: 'slideshow'}, // Your custom slideshow block
]
}The key difference is that custom blocks in Portable Text must be objects that contain your array, not arrays themselves. According to the array fields documentation, arrays need proper structure and the "of" property must define valid member types.
If you want the slideshow to appear inline with your text content, this object-based approach is the correct pattern. The array of images is now a field within the slideshow object, which can be properly embedded in your Portable Text content. This follows the same pattern described in the Block Content documentation for adding custom blocks like images and videos.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.