Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
For sure working from somewhere 🤘

DominikAngerer DominikAngerer

🏠
For sure working from somewhere 🤘
View GitHub Profile
@DominikAngerer
DominikAngerer / events.json
Last active Jan 15, 2021
Events and locations
View events.json
{
"events": [
]
}
@DominikAngerer
DominikAngerer / richTextField.js
Created Apr 16, 2020
RichText with sanitize-html
View richTextField.js
// 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 Apr 16, 2020
RichText with DOMPurify
View richTextField.js
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 Mar 20, 2020
Storyblok RichTextRenderer without token
View richTextField.js
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),
}
}
View index.js
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 Jun 5, 2019
Nuxt Builder for Now
View now.json
{
"version": 2,
"builds": [
{
"src": "nuxt.config.js",
"use": "@nuxtjs/now-builder",
"config": {}
}
],
"routes": [
View batman.txt
..........................................................................................................
..........................................................................................................
...............................*..........................................................................
............................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
View storyblok-import.js
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) => {
View _clear_cache.vue
<template>
<section class="util__container">
<h1>Cache Cleared</h1>
<br>
<p>Old Cache Version: {{oldCacheVersion}}</p>
<p>New Cache Version: {{newCacheVersion}}</p>
</section>
</template>
<script>
View storyblok-image-upload-function.js
methods: {
...
storyblokImageUpload(fileblob, filename, success, failure) {
this.api.client.post(
`/spaces/${this.spaceId}/assets`,
{ filename: filename },
{ headers: { Authorization: this.options.oauthToken } }, // uses the option with the name `oauthToken` which needs to be configured in the schema definition of the field you're using the plugin in.
).then((response) => {
let request = new XMLHttpRequest()