Sanity Library Reference Docs
    Preparing search index...

    Interface StructureBuilder

    Interface for the structure builder.

    interface StructureBuilder {
        context: StructureContext;
        defaultDocument: (
            options: { documentId?: string; schemaType: string },
        ) => DocumentBuilder;
        defaultInitialValueTemplateItems: () => InitialValueTemplateItemBuilder[];
        defaults: () => ListBuilder;
        divider: (spec?: Divider) => DividerBuilder;
        document: (spec?: PartialDocumentNode) => DocumentBuilder;
        documentList: (spec?: DocumentListInput) => DocumentListBuilder;
        documentListItem: (spec?: DocumentListItemInput) => DocumentListItemBuilder;
        documentTypeList: (
            typeNameOrSpec: string | DocumentTypeListInput,
        ) => DocumentListBuilder;
        documentTypeListItem: (typeName: string) => ListItemBuilder;
        documentTypeListItems: () => ListItemBuilder[];
        documentWithInitialValueTemplate: (
            templateId: string,
            parameters?: Record<string, unknown>,
        ) => DocumentBuilder;
        editor: (spec?: EditorNode) => DocumentBuilder;
        initialValueTemplateItem: (
            templateId: string,
            parameters?: Record<string, any>,
        ) => InitialValueTemplateItemBuilder;
        list: (spec?: ListInput) => ListBuilder;
        listItem: (spec?: ListItemInput) => ListItemBuilder;
        menuItem: (spec?: MenuItem) => MenuItemBuilder;
        menuItemGroup: (spec?: MenuItemGroup) => MenuItemGroupBuilder;
        menuItemsFromInitialValueTemplateItems: (
            templateItems: InitialValueTemplateItem[],
        ) => MenuItem[];
        orderingMenuItem: (ordering: SortOrdering) => MenuItemBuilder;
        orderingMenuItemsForType: (type: string) => MenuItemBuilder[];
        view: {
            component: (
                componentOrSpec?:
                    | ComponentType<any>
                    | Partial<ComponentView<Record<string, any>>>,
            ) => ComponentViewBuilder;
            form: (spec?: Partial<FormView>) => FormViewBuilder;
        };
    }
    Index

    Properties

    Context for the structure builder. See StructureContext

    defaultDocument: (
        options: { documentId?: string; schemaType: string },
    ) => DocumentBuilder

    By giving an object of options with documentID and its schema type receive the the respective Document builder

    Type declaration

      • (options: { documentId?: string; schemaType: string }): DocumentBuilder
      • Parameters

        • options: { documentId?: string; schemaType: string }

          an object holding the documentId and schemaType for the document node being resolved.

        Returns DocumentBuilder

        a Document builder. See DocumentBuilder

    defaultInitialValueTemplateItems: () => InitialValueTemplateItemBuilder[]

    Get an array of Item builders that take Initial Value template into consideration

    Type declaration

    defaults: () => ListBuilder

    Get the default List builder

    Type declaration

    divider: (spec?: Divider) => DividerBuilder

    Get a structure Divider

    Type declaration

      • (spec?: Divider): DividerBuilder
      • Parameters

        Returns DividerBuilder

        a DividerBuilder. See DividerBuilder

    document: (spec?: PartialDocumentNode) => DocumentBuilder

    By giving a partial Document Node receive the respective Document Builder

    Type declaration

    documentList: (spec?: DocumentListInput) => DocumentListBuilder

    By giving a Document List Input receive the respective Document List Builder

    Type declaration

    documentListItem: (spec?: DocumentListItemInput) => DocumentListItemBuilder

    By giving a Document List Item Input receive the respective Document List Item builder

    Type declaration

    documentTypeList: (
        typeNameOrSpec: string | DocumentTypeListInput,
    ) => DocumentListBuilder

    By giving a type name or Document Type List Input receive the respective Document List Builder

    Type declaration

    documentTypeListItem: (typeName: string) => ListItemBuilder

    By providing a type name receive a List Item builder

    Type declaration

    documentTypeListItems: () => ListItemBuilder[]

    Get an array of List Item builders

    Type declaration

    documentWithInitialValueTemplate: (
        templateId: string,
        parameters?: Record<string, unknown>,
    ) => DocumentBuilder

    By giving a templateID and a set of parameters receive a Document builder that takes InitialValueTemplate into account

    Type declaration

      • (templateId: string, parameters?: Record<string, unknown>): DocumentBuilder
      • Parameters

        • templateId: string

          a template ID

        • Optionalparameters: Record<string, unknown>

          an object of parameters

        Returns DocumentBuilder

        a Document builder. See DocumentBuilder

    editor: (spec?: EditorNode) => DocumentBuilder

    By giving a Editor Node receive the respective Document Builder

    Type declaration

    initialValueTemplateItem: (
        templateId: string,
        parameters?: Record<string, any>,
    ) => InitialValueTemplateItemBuilder

    By giving a templateID and a set of parameters receive an Item Builder that takes InitialValueTemplate into account

    Type declaration

    list: (spec?: ListInput) => ListBuilder

    By giving a List Input receive the respective Builder, otherwise return default ListBuilder builder

    Type declaration

    listItem: (spec?: ListItemInput) => ListItemBuilder

    By giving a List Item Input receive the respective Builder, otherwise return default ListItem builder

    Type declaration

    menuItem: (spec?: MenuItem) => MenuItemBuilder

    By giving a Menu Item receive the respective Builder, otherwise return default MenuItem builder

    Type declaration

    menuItemGroup: (spec?: MenuItemGroup) => MenuItemGroupBuilder

    By giving a Menu Item Group receive the respective Builder

    Type declaration

    menuItemsFromInitialValueTemplateItems: (
        templateItems: InitialValueTemplateItem[],
    ) => MenuItem[]

    By giving an array of initial value template receive an array of Menu Items, otherwise return default MenuItem builder

    Type declaration

    orderingMenuItem: (ordering: SortOrdering) => MenuItemBuilder

    By giving a sort ordering object receive a Menu Item Builder

    Type declaration

    orderingMenuItemsForType: (type: string) => MenuItemBuilder[]

    By giving a type receive a list of Menu Items ordered by it

    Type declaration

    view: {
        component: (
            componentOrSpec?:
                | ComponentType<any>
                | Partial<ComponentView<Record<string, any>>>,
        ) => ComponentViewBuilder;
        form: (spec?: Partial<FormView>) => FormViewBuilder;
    }

    View for structure

    Type declaration