Skip to content

Instantly share code, notes, and snippets.

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)
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'
@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><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 / 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
@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(
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div><textarea class="uk-width-1-1" v-model="model.rte_content" ref="mytextarea" id="mytextarea">Hello, World!</textarea></div>`,
methods: {
initWith() {
return {
plugin: 'atlas_rte',
rte_content: 'Hello world!'
}
},
@onefriendaday
onefriendaday / index.js
Created October 9, 2018 18:49
Simple contact form with Storyblok and Nodejs
/*
Instructions:
1. Install the dependencies with "npm init" and "npm install storyblok-js-client http"
1. Create a content type with a "message" field type
2. Exchange oauthToken (from the my account section of Storyblok) and spaceId
3. Start the server with "node index.js" and execute following curl request
curl -X POST \
http://127.0.0.1:3020 \
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(
fetch('https://api.storyblok.com/v1/cdn/datasource_entries?datasource=github-repositories&token=' + window.storyblok.config.accessToken)
.then(response => response.json())
.then(myJson => {
console.log(myJson)
})