Sanity Library Reference Docs
    Preparing search index...

    Function defineContentResource

    • Beta

      Defines a content resource as the Manage UI makes it: a custom permission of type sanity.document.filter.mode.

      defineContentResource({
      name: 'movies',
      documentTypes: ['movie'],
      })
      // config.filter: '_type == "movie"'

      Parameters

      • parameters: BlueprintContentResourceConfig

        The configuration of the content resource

        Deploying Permissions via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.

        Configuration for a content resource: a custom permission of type sanity.document.filter.mode, as the Manage UI makes it. This feature is subject to breaking changes.

        • Optional Betadescription?: string

          A description of the permission. Defaults to an empty string.

        • Optional BetadocumentTypes?: string[]

          The document types that the content resource applies to. Omit to apply to documents of any type.

        • Optional Betafilter?: string

          A GROQ filter that selects documents, e.g. branch == "london". It is joined to documentTypes with &&.

        • Betaname: string

          The name of the permission.

          Lowercase letters, numbers, hyphens, and underscores only. Must not start with sanity or res-.

        • Optional Betaproject?: string

          The project ID of the project that contains the permission.

          The project attribute must be defined if your blueprint is scoped to an organization and the stack has no default project.

        • Optional Betatitle?: string

          A human-readable title. Defaults to name.

      Returns BlueprintPermissionResource

      The permission resource

      defineContentResource({
      name: 'london-posts',
      title: 'London posts',
      documentTypes: ['post', 'event'],
      filter: 'branch == "london"',
      })
      // config.filter: '_type in ["post", "event"] && (branch == "london")'