Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
onefriendaday / regex-slug
Created November 10, 2017 13:22
Regex that destroys everything
/\A[A-Za-z0-9]+(?:(_*|-*|:)[A-Za-z0-9]+)*\z/
@onefriendaday
onefriendaday / html
Created November 22, 2017 16:16
Storyblok Standalone
<!DOCTYPE html>
<html>
<head></head>
<body>
<link href='//app.storyblok.com/css/index-latest.css' rel='stylesheet' type='text/css'></link>
<div id="root"></div>
<div id="page-load"><div><div></div></div></div>
<script type="text/javascript" src="//app.storyblok.com/js/app-latest.js"></script>
</body>
</html>
module.exports = {
watch: {
'model': {
handler: function (value) {
this.$emit('changed-model', value)
},
deep: true
}
},
created: function() {
const StoryblokClient = require('storyblok-js-client')
let Storyblok = new StoryblokClient({
accessToken: 'YOUR_TOKEN'
})
let lastPage = 1
for (var i = 1; i <= lastPage; i++) {
await Storyblok.get('cdn/stories', {
@onefriendaday
onefriendaday / backup.js
Last active January 22, 2018 18:26
Nodejs backup example
// Simple backup example in node.js
//
// How to use:
// npm install storyblok-js-client
//
// Create the folder 'backup'
//
// Create the file 'backup.js' and execute
// node ./backup.js
// 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 TOKEN and startWith
// 5. $ node index.js
app.get('/*', function(req, res) {
var path = url.parse(req.url).pathname;
path = path == '/' ? 'home' : path
Storyblok
.get(`stories/global`, {
version: req.query._storyblok ? 'draft': 'published'
})
.then((response) => {
Storyblok
url: function(storylink) {
return storylink.cached_url
}
// define a new content type "app"
{
"_uid": "autogenerated-uid",
"additionalAuthors": ["Global Tracking", "Fresh Produce"], // needs to be a multi option field
"author": "Supply Chain", // needs to be a single option field
"badges": [
"complete",
"token",
"featured",
"hot"
@onefriendaday
onefriendaday / searchblok.js
Created April 4, 2018 08:17
searchblok.js
<script>
import Util from './libs/Utils'
import App from './App.html'
import axios from 'axios'
import _ from 'lodash'
export default {
template: Util.template('#searchblok-app', App),
name: 'searchblok',
props: ['settings'],