studio/src/schemaTypes/. The directory is organized by category:
Schema categories
Documents
First-class content items that live at the top level of the dataset. Each has
_id, _type, and _rev. Documents are published and versioned independently.Blocks
Object types used inside
page.blocks[]. Created with the defineBlock helper — they inherit shared layout fields automatically.Objects
Embedded sub-objects without their own document identity, for example
seo, button, link, and portableText.Fields
Shared
defineField exports reused across multiple schemas. Currently only siteField — the multi-site routing discriminator.The defineBlock helper
Every page-builder block is created through defineBlock, defined in studio/src/schemaTypes/helpers/defineBlock.ts. It wraps Sanity’s defineType and automatically prepends the shared layout options fieldset (backgroundVariant, spacing, maxWidth) to every block.
variants option generates a variant radio field and wires hiddenByVariant so fields automatically hide/show when the editor switches variants — without writing custom hidden callbacks.
Block base fields
Every block created withdefineBlock inherits these layout controls in a collapsible Layout Options fieldset:
| Field | Type | Options |
|---|---|---|
backgroundVariant | string (radio) | white, light, dark, primary |
spacing | string (radio) | none, small, default, large |
maxWidth | string (radio) | narrow, default, full |
Schema registration in index.ts
All types must be imported and added to the schemaTypes array in studio/src/schemaTypes/index.ts before Sanity will recognize them:
createSchemaTypesForWorkspace(dataset) utility in workspace-utils.ts post-processes this array to hide the site field on the production dataset, so Capstone editors never see multi-site controls.
TypeGen: generating TypeScript types
Sanity TypeGen reads the registered schemas and running GROQ queries to produce fully-typed TypeScript interfaces. Run it after any schema or query change:sanity schema extract followed by sanity typegen generate and writes the output to astro-app/src/sanity.types.ts. All query result types (e.g. PAGE_BY_SLUG_QUERY_RESULT, ALL_SPONSORS_QUERY_RESULT) come from this generated file.