Skip to content

Instantly share code, notes, and snippets.

app.$storyapi.get('cdn/stories/article', {
cv: store.state.cacheVersion,
resolve_links: '1'
})
async asyncData({app, store}) {
let [article, authors] = await Promise.all([
app.$storyapi.get('cdn/stories/article', {
cv: store.state.cacheVersion
}),
app.$storyapi.get('cdn/stories', {
starts_with: 'authors/',
cv: store.state.cacheVersion
})
])
@onefriendaday
onefriendaday / seo-plugin.js
Created June 27, 2018 15:14
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>
@onefriendaday
onefriendaday / sortable.js
Created June 1, 2018 08:29
sortable directive
var Sortable = require('sortablejs')
module.exports = {
update: function (val) {
var self = this
this.sortable = Sortable.create(this.el, {
animation: 150,
handle: '.sortable__handle',
onStart: function (e) {
@onefriendaday
onefriendaday / folder-selector.js
Created April 19, 2018 14:06
Folder Selector Plugin example
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div><select class="uk-width-1-1" v-model="model.value">
<option :key="option.value" v-for="option in options">{{ option.name }}</option>
</select></div>`,
data() {
return {
options: []
}
},
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `
<div class="uk-clearfix">
<input class="uk-hidden" type="file" multiple="multiple" @change="changeFiles($event)" />
<div class="uk-flex uk-margin-small-bottom" v-for="(key, item) in model.files">
<img class="image" :src="item.url.replace('a.storyblok.com', 'img2.storyblok.com/160x90/filters:fill(auto,0)')">
<input type="text" class="uk-form-small uk-flex-item-auto" v-model=item.url>
<button @click.prevent="removeFile(key)" class="uk-button uk-button-small uk-margin-small-left"><i class="uk-icon-close"></i></button>
@onefriendaday
onefriendaday / searchblok.js
Created April 4, 2018 08:17
searchblok.js
<script>
import Util from './libs/Utils'
import App from './App.html'
import axios from 'axios'
import _ from 'lodash'
export default {
template: Util.template('#searchblok-app', App),
name: 'searchblok',
props: ['settings'],
// define a new content type "app"
{
"_uid": "autogenerated-uid",
"additionalAuthors": ["Global Tracking", "Fresh Produce"], // needs to be a multi option field
"author": "Supply Chain", // needs to be a single option field
"badges": [
"complete",
"token",
"featured",
"hot"
url: function(storylink) {
return storylink.cached_url
}
app.get('/*', function(req, res) {
var path = url.parse(req.url).pathname;
path = path == '/' ? 'home' : path
Storyblok
.get(`stories/global`, {
version: req.query._storyblok ? 'draft': 'published'
})
.then((response) => {
Storyblok