Issue with importing and defining schemas in Sanity.io
I can see the issue! The problem is that you're trying to use adBanner as a document type, but then referencing it directly in an array's of property. When you use type: "document", you're creating a top-level document type that appears in your Studio's main navigation. However, you can't directly embed document types in arrays - you need to either use references or change adBanner to an object type.
Here are two ways to fix this:
Option 1: Change adBanner to an object type (Recommended)
If you want adBanner items to be embedded directly within the marketing array, change it from a document to an object:
export default {
title: "Ad Banner",
name: "adBanner",
type: "object", // Changed from "document" to "object"
fields: [
{
title: "Promo Banner type",
name: "promoType",
type: "string",
},
{
title: "Promo Heading",
name: "promoHeading",
type: "string",
},
{
title: "Promo Text",
name: "promoText",
type: "array",
of: [{ type: "block" }],
},
{
title: "Affiliate marketing link",
name: "promoLink",
type: "url",
},
{
title: "Promo product image",
name: "promoImage",
type: "image",
},
],
};Then you'll need a parent document to hold the marketing array:
export default {
title: "Marketing Page",
name: "marketingPage",
type: "document",
fields: [
{
title: "Marketing",
name: "marketing",
type: "array",
of: [{ type: "adBanner" }],
},
],
};Option 2: Use references to keep adBanner as a document
If you want adBanner to remain a standalone document type (appearing in your Studio navigation), use references:
export default {
title: "Marketing Page",
name: "marketingPage",
type: "document",
fields: [
{
title: "Marketing",
name: "marketing",
type: "array",
of: [
{
type: "reference",
to: [{ type: "adBanner" }],
},
],
},
],
};The key difference: Object types are embedded content that only exist within their parent document. Document types are standalone entries that can be referenced from multiple places. For your use case, Option 1 (object type) is probably what you want unless you need to reuse the same ad banners across multiple marketing campaigns.
Make sure both schema files are properly exported in your schema configuration file (usually schema/index.ts or similar) so Sanity knows about both types!
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.