Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
onefriendaday / gatsby-node.js
Created September 29, 2018 18:24
Global settings story with Gatsby and Storyblok
const Promise = require('bluebird')
const path = require('path')
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
const storyblokEntry = path.resolve('src/templates/storyblok-entry.js')
graphql(
@onefriendaday
onefriendaday / xml-export.js
Last active September 28, 2018 08:02
XML export of stories
// About
// This script exports all stories as XML in a specific folder
// -------
// How to install?
// 1. Create a folder for the project and inside a "data" folder
// 2. $ npm init
// 3. $ npm install storyblok-js-client --save
// 4. Exchange SPACE_ID and YOUR_OAUTH2_TOKEN and optionally startWith to export only one specific folder
// 5. $ node xml-export.js
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div><div v-if="tinyLoaded"><plugin-mce :value=model.content @input=handleInput :config=config></plugin-mce></editor></div></div>`,
data() {
return {
config: {
plugins: 'fullscreen link lists code visualblocks',
menubar: false,
toolbar: 'styleselect | link | numlist bullist | removeformat code',
style_formats: [{ title: 'Block', items: [{ title: 'Paragraph', format: 'p' }, { title: 'Header 1', format: 'h1' }, { title: 'Header 2', format: 'h2' }, { title: 'Header 3', format: 'h3' }, { title: 'Header 4', format: 'h4' }, { title: 'Header 5', format: 'h5' }, { title: 'Header 6', format: 'h6' }, { title: 'Blockquote', format: 'blockquote' }] }, { title: 'Inline', items: [{ title: 'Bold', icon: 'bold', format: 'bold' }, { title: 'Italic', icon: 'italic', format: 'italic' }] }, { title: 'Alignment', items: [{ title: 'Text Right', icon: 'alignright', selector: 'p, div, blockquote', classes: 'text-right' }
@onefriendaday
onefriendaday / index.js
Created September 27, 2018 17:17
Nodejs-storyblok-example
const StoryblokClient = require('storyblok-js-client')
const Storyblok = new StoryblokClient({
oauthToken: 'YOUR_OAUTH_TOKEN'
})
let start = async function() {
for (var i = 0; i < 20; i++) {
await Storyblok.get('spaces/YOUR_SPACE_ID/stories/YOUR_STORY_ID')
console.log(i)
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div class="uk-flex">
<input class="uk-margin-right" v-model="model.color" type="color" />
<input class="uk-width-1-1" v-model="model.color" /></div>`,
methods: {
initWith() {
return {
plugin: 'example_plugin',
color: '#f40000'
Single Story
- questions (type: Blocks)
-- [component]question
--- answers (type: Blocks)
---- [component]answer
----- name (type: text)
---- [component]answer
----- name (type: text)
---- [component]answer
----- name (type: text)
@onefriendaday
onefriendaday / Fieldtype.js
Created July 11, 2018 08:34
Demonstrates usage of sb-asset-selector
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div>
<sb-asset-selector :uid="uid" field="image"></sb-asset-selector>
<input type="text" class="uk-margin-top uk-width-1-1" v-model="model.image" />
</div>`,
methods: {
initWith() {
return {
plugin: 'example_plugin',
fetch(
`https://mapi.storyblok.com/v1/spaces/${SPACE_ID}/stories`,
{
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": POWER_TOKEN
},
body: JSON.stringify({
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div>
<div class="uk-margin-bottom uk-text-center" v-if="model.icon">
Current icon: <i :class="model.type + ' ' + model.icon"></i>
<small style="cursor:pointer;" @click="removeIcon">(remove)</small>
</div>
<input class="uk-width-1-1 uk-margin-bottom" v-model="search" placeholder="Search icons" />
<span class="icon-link" @click="setIcon(icon)" :key="icon.icon" v-for="icon in filteredIcons" style="margin: 5px; display: inline-block;">
<i style="cursor:pointer;" :class="icon.type + ' ' + icon.icon"></i>
@onefriendaday
onefriendaday / export.js
Created July 6, 2018 07:31
Storyblok Iconselector
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div>
<div class="uk-margin-bottom uk-text-center" v-if="model.icon">
Current icon: <i :class="model.type + ' ' + model.icon"></i>
<small style="cursor:pointer;" @click="removeIcon">(remove)</small>
</div>
<input class="uk-width-1-1 uk-margin-bottom" v-model="search" placeholder="Search icons" />
<span class="icon-link" @click="setIcon(icon)" :key="icon.icon" v-for="icon in filteredIcons" style="margin: 5px; display: inline-block;">
<i style="cursor:pointer;" :class="icon.type + ' ' + icon.icon"></i>