Skip to content

Commit

Permalink
feat: expose createSanityDataAttribute utility (#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdunk authored Aug 13, 2024
1 parent b67f19e commit ffd23c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/content/2.helpers/5.visual-editing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Visual Editing

---

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.

See the [Sanity documentation](https://www.sanity.io/docs/visual-editing-overlays#cb95b19a0263) for more information.

## Example

```vue
<template>
<h1 :data-sanity="createSanityDataAttribute({
id: 'the-godfather',
type: 'movie',
path: 'title',
})">The Godfather</h1>
</template>
```
1 change: 1 addition & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ export default defineNuxtModule<SanityModuleOptions>({
{ name: 'useSanityLiveMode', from: composablesFile },
{ name: 'useSanityVisualEditing', from: composablesFile },
{ name: 'useSanityVisualEditingState', from: composablesFile },
{ name: 'createDataAttribute', from: '@sanity/visual-editing', as: 'createSanityDataAttribute' },
])
}

Expand Down

0 comments on commit ffd23c4

Please sign in to comment.