From 43aeeb12ba4eaf62fca8ab2b61f741d3c1693dbf Mon Sep 17 00:00:00 2001 From: nadaamd Date: Mon, 24 Aug 2026 15:21:36 +0200 Subject: [PATCH] feat(schema): add relation editor option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lets a string field declare that it references a document of another collection, so Studio can render a picker instead of a free-text input. Types only: `.editor()` already merges its whole argument into the generated schema, so `relation` reaches Studio today — this stops `input: 'relation'` from needing a cast at every call site. Co-Authored-By: Claude Opus 5 (1M context) --- src/types/schema.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/types/schema.ts b/src/types/schema.ts index 9d340ffa8..f416e6a40 100644 --- a/src/types/schema.ts +++ b/src/types/schema.ts @@ -47,14 +47,21 @@ export interface ContentConfig { } export interface EditorOptions { - input?: 'media' | 'icon' | 'textarea' // Override the default input for the field + input?: 'media' | 'icon' | 'textarea' | 'relation' // Override the default input for the field hidden?: boolean // Do not display the field in the editor iconLibraries?: string[] // List of icon libraries to use for the icon input + relation?: RelationOptions // Collection referenced by the field, for the relation input label?: string // Override auto-generated label with a custom one description?: string // When defined, set a description for the field tooltip?: string // When defined, set a tooltip info-bubble next to the label } +export interface RelationOptions { + collection: string // Name of the referenced collection, as declared in the content config + valueField?: 'slug' | 'path' | 'stem' | (string & {}) // Field of the referenced document written to the file, defaults to `slug` (its file name) + labelField?: string // Field of the referenced document displayed in the editor, defaults to `name` then `title` +} + export interface ContentStandardSchemaV1 extends StandardSchemaV1 { $content?: ContentConfig }