Skip to content

Instantly share code, notes, and snippets.

View DominikAngerer's full-sized avatar
🏠
For sure working from somewhere 🤘

DominikAngerer DominikAngerer

🏠
For sure working from somewhere 🤘
View GitHub Profile
@DominikAngerer
DominikAngerer / export-component-names.js
Created August 13, 2021 10:47
Export Storyblok Component Names
// Install dependency: npm install storyblok-js-client
const StoryblokClient = require('storyblok-js-client')
// This token allows CRUD operations to all your spaces and can be found in the
// "my account" section of our app: https://app.storyblok.com/#!/me/account
// DO NOT COMMIT THAT OAUTHTOKEN!!
const oauthToken = 'your_oauth_token'
// Initialize the client with the oauth token
const Storyblok = new StoryblokClient({
@DominikAngerer
DominikAngerer / storyloader.js
Created July 23, 2021 14:35
Starting point for custom storyloader field types
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div>
<input class="uk-width-1-1 uk-margin-small-bottom" v-model="search" placeholder="Search" @input="searchStories" />
<select multiple="true" class="uk-width-1-1" v-model="selected">
<option v-for="(story, index) in stories" v-bind:key="story.uuid" :value="story.uuid">{{story.name}}</option>
</select>
<button class="uk-width-1-1 uk-margin-top uk-button-primary uk-button" @click="saveSelection">Save</button>
</div>`,
data() {
@DominikAngerer
DominikAngerer / events.json
Last active January 15, 2021 13:14
Events and locations
{
"events": [
]
}
@DominikAngerer
DominikAngerer / richTextField.js
Created April 16, 2020 22:10
RichText with sanitize-html
// npm install sanitize-html
const sanitizeHtml = require('sanitize-html');
// npm install storyblok-js-client
const StoryblokClient = require('storyblok-js-client')
// Storyblok is now available as variable which contains the richTextResolver functionality
const Storyblok = new StoryblokClient({})
function createMarkup(storyblokHTML) {
return {
@DominikAngerer
DominikAngerer / richTextField.js
Created April 16, 2020 22:07
RichText with DOMPurify
const StoryblokClient require('storyblok-js-client')
const createDOMPurify = require('dompurify')
const { JSDOM } = require('jsdom')
// Storyblok is now available as variable which contains the richTextResolver functionality
const Storyblok = new StoryblokClient({})
// For Node this needs to use the jhttps://github.com/cure53/DOMPurify#okay-makes-sense-lets-move-on
const jsDomWindow = new JSDOM('').window;
const DOMPurify = createDOMPurify(jsDomWindow);
@DominikAngerer
DominikAngerer / richTextField.js
Created March 20, 2020 13:06
Storyblok RichTextRenderer without token
import StoryblokClient from 'storyblok-js-client'
// Storyblok is now available as variable which contains the richTextResolver functionality
const Storyblok = new StoryblokClient({})
function createMarkup(storyblokHTML) {
return {
__html: Storyblok.richTextResolver.render(storyblokHTML),
}
}
const Storyblok = require('storyblok-js-client') // npm install storyblok-js-client
const MAPI_TOKEN = "your_oauth_token"
const spaceId = 73358 // your configured space id folder
const yourFolderId = 5663791 // your parent folder
let StoryblokClient = new Storyblok({
oauthToken: MAPI_TOKEN
})
@DominikAngerer
DominikAngerer / now.json
Created June 5, 2019 13:14
Nuxt Builder for Now
{
"version": 2,
"builds": [
{
"src": "nuxt.config.js",
"use": "@nuxtjs/now-builder",
"config": {}
}
],
"routes": [
..........................................................................................................
..........................................................................................................
...............................*..........................................................................
............................Y@@@@Y.....................................E@@@@E.............................
...........................E@@WR@@@...................................E@@WW@@@*...........................
.........................E@@@GGGG@@W.................................:@@WGGGW@@Y..........................
........................Y@@WGGGGGR@@E................................@@QGGGGGW@@G.........................
.......................E@@WGGGGGGGW@@:..........*YEYEEEE*...........@@@GGGGGGGG@@@........................
......................R@@GGGGGGGGGGQ@@...EEG@@@@@@@@@@@@@@@@@REY:..Y@@GGGGGGGGGGQ@@.......................
.....................G@@GGGGGGGGGGGG@@@@@@WWWWGGGGGGGGGGGGGRW
const axios = require('axios')
const fs = require('fs')
const netrc = require('netrc')
const os = require('os')
const path = require('path')
const host = 'api.storyblok.com'
const args = process.argv
let space = ''
args.forEach((arg) => {