blocks
blocks<
TFieldMeta>(options):BlocksField<TFieldMeta>
Defined in: packages/core/src/fields/blocks/config.ts:101
Creates a blocks field with all defaults applied.
Validates that all block slugs are unique within this field. Each item
stored in Convex carries blockType, blockName, and id in addition
to the block’s own fields.
Type Parameters
Section titled “Type Parameters”TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends BaseFieldMeta = BaseFieldMeta
Parameters
Section titled “Parameters”options
Section titled “options”BlocksFieldInput<TFieldMeta>
Blocks field configuration. blocks is required.
Returns
Section titled “Returns”BlocksField<TFieldMeta>
Resolved blocks field definition.
Throws
Section titled “Throws”If two or more block definitions share the same slug.
Example
Section titled “Example”const heading = defineBlock({ slug: "heading", label: "Heading", fields: { text: text({ required: true }) } })const paragraph = defineBlock({ slug: "paragraph", label: "Paragraph", fields: { content: text({ required: true }) } })
defineCollection({ fields: { body: blocks({ label: "Body", blocks: [heading, paragraph], labels: { singular: "section", plural: "sections" }, }), },})- BlocksFieldInput for the full input type
- BlocksField for the resolved output type