Skip to content

Instantly share code, notes, and snippets.

@DominikAngerer
Last active July 13, 2018 16:13
Show Gist options
  • Save DominikAngerer/d8461c21d9ae476d8629320448a87c86 to your computer and use it in GitHub Desktop.
Save DominikAngerer/d8461c21d9ae476d8629320448a87c86 to your computer and use it in GitHub Desktop.
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div><button class="uk-button uk-width-1-1" v-on:click="publishToProduction">Publish to Production</button></div>`,
methods: {
initWith() {
return {
plugin: 'publish-to-production'
}
},
pluginCreated() {
console.log('plugin:created')
},
publishToProduction() {
// Send actual request to rebuild your website (after X websites where published)
alert('Send actual request to rebuild your website (after X websites where published)')
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://YOUR_ENDPOINT");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
}
},
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