
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou're on the right track! Yes, using an array of objects where each object represents a different section type is exactly how you'd approach this in Sanity. This pattern is called Block Content or modular content, and it's one of Sanity's strengths.
Here's how it works:
Define your blog post schema with an array field that accepts different object types:
defineField({
name: 'content',
type: 'array',
of: [
{
type: 'object',
name: 'fullWidthImage',
fields: [
{name: 'image', type: 'image'},
{name: 'alt', type: 'string'}
]
},
{
type: 'object',
name: 'textWithImageLeft',
fields: [
{name: 'text', type: 'text'},
{name: 'image', type: 'image'}
]
},
{
type: 'object',
name: 'textWithImageRight',
fields: [
{name: 'text', type: 'text'},
{name: 'image', type: 'image'}
]
},
{
type: 'object',
name: 'blockQuote',
fields: [
{name: 'quote', type: 'text'},
{name: 'author', type: 'string'}
]
},
{
type: 'object',
name: 'cta',
fields: [
{name: 'heading', type: 'string'},
{name: 'buttonText', type: 'string'},
{name: 'link', type: 'url'}
]
}
]
})Each object in the array maps perfectly to React components. You'd query the data and map over the array:
{post.content?.map((block) => {
switch(block._type) {
case 'fullWidthImage':
return <FullWidthImage key={block._key} {...block} />
case 'textWithImageLeft':
return <TextImageLeft key={block._key} {...block} />
case 'textWithImageRight':
return <TextImageRight key={block._key} {...block} />
case 'blockQuote':
return <BlockQuote key={block._key} {...block} />
case 'cta':
return <CTA key={block._key} {...block} />
default:
return null
}
})}You can also include Portable Text blocks in the same array if you want rich text sections alongside your custom components:
of: [
{type: 'block'}, // Rich text paragraphs with formatting
{type: 'fullWidthImage'},
{type: 'textWithImageLeft'},
// ... other custom objects
]This gives content editors the flexibility to mix formatted text with your custom section types.
This pattern is exactly what Sanity's Block Content system is designed for - treating your content like "Lego bricks" that can be assembled in different ways while maintaining structure and consistency. Each block in the array automatically gets a _key property for React's key prop, and the _type property tells you which component to render.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store