Sanity Library Reference Docs
    Preparing search index...

    Function documentIdEquals

    • Checks if the document ID documentId has the same ID as equalsDocumentId, ignoring the draft prefix.

      Parameters

      • documentId: string

        The document ID to check

      • equalsDocumentId: string

        The document ID to check against

      Returns boolean

      true if the document IDs are equal, false otherwise

      Draft vs published document ID, but representing the same document:

      // Prints "true":
      console.log(documentIdEquals('drafts.agot', 'agot'));

      Different documents:

      // Prints "false":
      console.log(documentIdEquals('hp-tcos', 'hp-hbp'));