Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Created June 27, 2018 15:14
Show Gist options
  • Save onefriendaday/0afe7c1c49bb1e2ba0dda12b687a7105 to your computer and use it in GitHub Desktop.
Save onefriendaday/0afe7c1c49bb1e2ba0dda12b687a7105 to your computer and use it in GitHub Desktop.
Storyblok SEO Plugin
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `
<div>Google snippet preview:
<div style="margin:5px 0 15px;padding:10px;color:#000;background:#fff">
<div style="color:blue;text-decoration:underline">{{ model.title }}</div>
<div style="color:green">yoursite.com/example</div>
<div>{{ model.description }}</div>
</div>
<div class=uk-form-row>
<label>SEO Title</label>
<input type=text v-model=model.title class=uk-width-1-1>
</div>
<div class=uk-form-row>
<label>Meta description</label>
<textarea rows=4 v-model=model.description class=uk-width-1-1></textarea>
<div>{{ charCount }} of 156 chars used</div>
</div>
</div>
`,
methods: {
initWith() {
return {
plugin: 'my-seo-plugin',
title: '',
description: ''
}
},
pluginCreated() {
console.log('plugin:created')
}
},
computed: {
charCount: function charCount() {
return ((this.model || {}).description || '').length;
}
},
watch: {
'model': {
handler: function (value) {
this.$emit('changed-model', value);
},
deep: true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment