N
Nuxt3mo ago
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>
<template>
<h1 :data-sanity="createSanityDataAttribute({
id: 'the-godfather',
type: 'movie',
path: 'title',
})">The Godfather</h1>
</template>
2 Replies
kapa.ai
kapa.ai3mo ago
Hi @Thomas. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry, but the knowledge sources provided do not contain any information about the Sanity Nuxt module or the createSanityDataAttribute helper function. There is no mention of this function, its usage, or any best practices regarding checking for preview mode before using it. Therefore, I cannot confirm whether it is safe to use without such a check or provide guidance on resolving the server error you encountered. If you have access to the official documentation for the Sanity Nuxt module, I recommend consulting it directly for more details. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@1369008538453807337> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?