Sanity Library Reference Docs
    Preparing search index...

    Function getCommentTargetDocumentRef

    • Alpha

      Build the global document reference a comment stores in target.document._ref, without a client.

      client.collaboration.comments.getTargetDocumentRef reads the resource off the client's configuration and calls this. Use this directly when the resource is already at hand and no client should be involved, for example inside a state selector that has to stay free of side effects.

      The reference always names the published document: a draft or version ID is reduced to its published form first.

      Parameters

      • resource: CommentResource

        The resource the comments are stored against, as ClientConfig['resource'] takes it

      • documentId: string

        Document ID, in published, draft or version form

      Returns `${string}:${string}:${string}`

      Global document reference, of the form resourceType:resourceId:documentId

      getCommentTargetDocumentRef({type: 'dataset', id: 'abc123.production'}, 'drafts.doc-1')
      // 'dataset:abc123.production:doc-1'