Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Created February 5, 2020 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onefriendaday/a646fadb462367e8682fc540878c351d to your computer and use it in GitHub Desktop.
Save onefriendaday/a646fadb462367e8682fc540878c351d to your computer and use it in GitHub Desktop.
Users a parameter check to only make elements of current story editable.
Vue.directive('my-editable', {
bind: function(el, binding) {
if (typeof binding.value._editable === 'undefined') {
return
}
var options = JSON.parse(binding.value._editable.replace('<!--#storyblok#', '').replace('-->', ''))
if (options.id != window.storyblok.getParam('_storyblok')) {
return
}
el.setAttribute('data-blok-c', JSON.stringify(options))
el.setAttribute('data-blok-uid', options.id + '-' + options.uid)
addClass(el, 'storyblok__outline')
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment