Skip to content

chrispecoraro/sanity-api-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

The "missing" Sanity Schema API doc

schema field properties:

hidden: boolean or function example:

  • hidden: true

  • hidden: ({currentUser, value, parent, document}) => { return // },

readOnly: boolean or function example:

hidden: true
- hidden: ({currentUser, value, parent, document}) => {
        // option with value
        return value < 5
       // option with parent
        return parent?.externalLink !== undefined
        // option currentUser
        return !currentUser.roles.find(({name}) => name === 'administrator')
      },
    },

function parameter is an object argument with the following properties:

name: document type: object

The current state of the document with all its values. Remember that it can return undefined. You can use optional chaining to avoid errors in the console, for example, document?.title.

name: parent type: object | undefined

The values of the field's parent. This is useful when the field is part of an object type. Remember that it can return undefined. You can use optional chaining to avoid errors in the console, for example, parent?.title. If it's a root field, it will contain the document's values.

name: value type: any

The field's current value.

name: currentUser type: object

The current user with the following fields:

  • email (string)
  • id (string)
  • name (string)
  • profileImage (string)role (string)
  • roles (array of objects with name, title, description)

About

The "missing" API doc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published