This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const StoryblokClient = require('storyblok-js-client') | |
const Storyblok = new StoryblokClient({ | |
accessToken: 'YOUR_TOKEN' | |
}) | |
Storyblok.setComponentResolver((component, blok) => { | |
switch(component) { | |
case 'my_button': | |
return `<button>${blok.button_text}</button>` | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For Nuxtjs and Gridsome: | |
<template> | |
<div> | |
<div v-html="richtext"></div> | |
</div> | |
</template> | |
<script> | |
export default { | |
props: ['text'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Fieldtype = { | |
mixins: [window.Storyblok.plugin], | |
template: `<div><select v-model="model.example"><option :value="item.uuid" :key="item.uuid" v-for="item in stories">{{item.name}}</option></select></div>`, | |
data() { | |
return {stories: []} | |
}, | |
methods: { | |
initWith() { | |
return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Fieldtype = { | |
mixins: [window.Storyblok.plugin], | |
data() { | |
return { | |
loading: true, | |
open: false, | |
colors: ['#F64272', '#F6648B', '#F493A7', '#F891A6', '#FFCCD5', ''] | |
} | |
}, | |
template: `<div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function replaceAll(tree) { | |
var traverse = function (jtree) { | |
if (jtree.constructor === String) { | |
jtree = jtree.replace(new RegExp('a.storyblok.com', 'g'), 'img2.storyblok.com') | |
} else (jtree.constructor === Array) { | |
for (var item = 0; item < jtree.length; item++) { | |
traverse(jtree[item]) | |
} | |
} else if (jtree.constructor === Object) { | |
for (var treeItem in jtree) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PagesController < ApplicationController | |
def index | |
response.headers['X-FRAME-OPTIONS'] = 'ALLOWALL' | |
client = Storyblok::Client.new( | |
logger: logger, | |
cache_version: Time.now.to_i, | |
token: 'Dv2ok3DqODzzb8QUuN2XCgtt', | |
version: 'draft' | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pluginCreated() { | |
this.$sb.getScript('https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.7/js/uikit-core.min.js'); | |
this.$nextTick(() => { | |
this.padding = this.model.padding; | |
this.margin = this.model.margin; | |
}) | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Fieldtype = { | |
mixins: [window.Storyblok.plugin], | |
data() { | |
return { | |
advancedOpen: false | |
} | |
}, | |
template: `<div> | |
<div class="uk-margin-small-bottom"> | |
Google preview |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Fieldtype = { | |
mixins: [window.Storyblok.plugin], | |
template: `<div><textarea v-model="model.content" id="mytextarea"></textarea></div>`, | |
methods: { | |
initWith() { | |
return { | |
plugin: 'wysiwyg-tinymce', | |
content: '' | |
} | |
}, |