Using Portable Text with Gatsby and Sanity, including querying data and defining content fields.
export default {
...
type: "document",
fields: [
...
{
title: "Content",
name: "content",
type: "array",
of: [
{ type: 'block' },
{ type: 'image' },
],
},
],
}interface Page implements Node {
id: ID!
...
_rawContent: <insert-something-here>!
}JSONand then the corresponding type in typescript can be
ArbitraryTypedObject. I couldn't glean that from the docs, but reading the generated schema.gql and tooltips got me there. I'd still like to see a proper example. What I have still doesn't work for images.
Was this answer helpful?
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.