NuxtN
Nuxt7mo ago
3 replies
Thomas

Visual Editing with Sanity Nuxt module

According to the documentation, a createSanityDataAttribute helper function is available to manually map the content in a component to its source code. But when I use this code locally, it creates a server error "createSanityDataAttribute" is not a function. Is this function not safe to use wihout checking first if we are in preview mode?


When visual editing is enabled, this module exports a createSanityDataAttribute helper function which allows you to manually map content in a component to its source. It is globally available throughout your project (both within your server routes and your Vue app) via auto-imports.

<template>
  <h1 :data-sanity="createSanityDataAttribute({
    id: 'the-godfather',
    type: 'movie',
    path: 'title',
  })">The Godfather</h1>
</template>
Was this page helpful?