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
<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>
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()
// npm install storyblok-js-client
const StoryblokClient = require('storyblok-js-client')
// Initialize the client with the oauth token so you're
// authenticated for the management API
const Storyblok = new StoryblokClient({
oauthToken: 'YOUR_OAUTH_TOKEN'
})
const spaceId = 'your_space_id'
let page = 1
const Fieldtype = {
mixins: [window.Storyblok.plugin],
data() {
return {
ich_bin_eine_state_variable_die_nicht_im_model_beinhaltet_ist: true,
ich_darf_nicht_model_heissen: true
}
},
template: `<div>
<input class="uk-width-1-1" v-model="model.example" />
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div>
<markdown-field :uid="uid" :model="model.original" :schema="schema" @changed="update" key="original"></markdown-field>
</div>`,
methods: {
initWith() {
return {
plugin: 'markdown-html',
original: '',
@DominikAngerer
DominikAngerer / get-all-spaces.js
Created February 20, 2019 16:31
get-all-spaces.js
// npm install storyblok-js-client
const StoryblokClient = require('storyblok-js-client')
// Initialize the client with the oauth token so you're
// authenticated for the management API
const Storyblok = new StoryblokClient({
oauthToken: 'YOUR_OAUTH_TOKEN'
})
const start = async () => {
@DominikAngerer
DominikAngerer / index.vue
Created February 15, 2019 16:18
Nuxt _language/index.vue
<template>
<section class="util__container">
<component v-if="story.content.component" :key="story.content._uid" :blok="story.content" :is="story.content.component"></component>
</section>
</template>
<script>
export default {
data () {
return { story: { content: {} } }
// Option 1
// if you know that you only want 2
let per_page = 100
let responses = await Promise.all([
app.$storyapi.get('cdn/stories/', {
starts_with: 'posts/',
per_page: per_page,
page: 1
}),
app.$storyapi.get('cdn/stories/', {
[ { "name":"1" ,"value":"Stefan Fuchs.png" } ,{ "name":"3" ,"value":"Stefan Fuchs.png" } ,{ "name":"4" ,"value":"heaven.jpg" } ,{ "name":"5" ,"value":"heaven.png" } ]
@DominikAngerer
DominikAngerer / check-for-unused-components.js
Created January 17, 2019 21:43
Check for unused components in Storyblok
// 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({