Skip to content

Instantly share code, notes, and snippets.

View mornir's full-sized avatar
🎮
Gaming

Jérôme Pott mornir

🎮
Gaming
View GitHub Profile
@mornir
mornir / preview.vue
Last active July 6, 2020 13:10
Preview content from Sanity, to be placed at the root of the pages directory
<template>
<component :is="currentComponent"
v-if="draft"
:person="draft"
:page="draft" />
<p v-else>{{ msg }}</p>
</template>
@mornir
mornir / IEBanner.vue
Created November 16, 2019 08:49
Warn Banner for IE11
<template>
<div id="banner"
class="bg-red-200 px-6 py-2 text-center">
<p class="font-semibold inline">⚠ Diese Webseite wurde nicht für Internet Explorer 11 optimiert. Wir empfehlen <a href="https://www.mozilla.org"
target="_blank"
rel="noopener"
class="underline">Mozilla Firefox</a> , <a href="https://www.microsoft.com/en-us/windows/microsoft-edge"
target="_blank"
rel="noopener"
class="underline">Microsoft Edge</a> oder <a href="https://www.google.com/chrome/"
@mornir
mornir / recover-schema.md
Created November 13, 2019 13:49 — forked from bjoerge/recover-schema.md
How to recover lost schema from *.sanity.studio.md

First, go to https://.sanity.studio, and open the developer console (usually by one of the keyboard shortcuts Command+Option+I, F12 or Control+Shift+I depending on what browser/platform you are using)

Steps

  1. Open the Sources tab
  2. Find the app.bundle.js file in the sidebar tree view.
  3. Hit the pretty print source button
  4. Locate your schema types by searching (e.g. try searching for one of your custom types) it in the source view.
@mornir
mornir / FuriganaInput.js
Last active September 20, 2019 19:19
A Sanity custom input component for generating furigana from kanji
import React from 'react'
import TextInput from 'part:@sanity/components/textinputs/default'
import FormField from 'part:@sanity/components/formfields/default'
import Button from 'part:@sanity/components/buttons/default'
import PropTypes from 'prop-types'
import ky from './ky'
const Furigana = require('gem-furigana').Furigana
import {
@mornir
mornir / card.vue
Created September 9, 2019 07:03
Card component
<template>
<figure>
<v-lazy-image :src="img"
:src-placeholder="lqip"
class="w-full object-cover"
:alt="alt" />
<figcaption class="mt-3 max-w-sm">
<span class="block font-bold text-2xl leading-tight">{{ title }}</span>
<span class="block text-base tracking-wide">{{ subtitle }}</span>
</figcaption>
@mornir
mornir / migrate.js
Created August 29, 2019 18:02
Migrate data from Streaks to Quitzilla
const csv = require('csvtojson')
const sqlite3 = require('sqlite3').verbose()
const jsonSql = require('json-sql')()
const csvFilePath = 'XXX.csv'
function getTimeStamp(str) {
const year = parseInt(str.slice(0, 4))
const month = parseInt(str.slice(4, 6)) - 1
const day = parseInt(str.slice(6, 8))
@mornir
mornir / list_file.js
Created August 12, 2019 18:45
Netlify Cloud Function List file from Google Drive
const {google} = require('googleapis');
const path = require('path');
const fs = require('fs');
function getCredentials() {
const filePath = path.join(__dirname, 'keys.json');
if (fs.existsSync(filePath)) {
return require(filePath);
}
if (process.env.CREDENTIALS) {
@mornir
mornir / index.js
Created August 5, 2019 08:35 — forked from dan-dr/index.js
Sanity Backup to Dropbox on webtask.io
const sanity = require('@sanity/client')
const fs = require('fs')
const EOL = require('os').EOL
const flatMap = require('lodash.flatmap')
const { subDays, isBefore } = require('date-fns')
const sanityExport = require('@sanity/export')
/**
* @param context {WebtaskContext}
*/
@mornir
mornir / merge_clients.js
Created June 22, 2019 10:41
Merge preview and client sanity
import Vue from 'vue'
import imageUrlBuilder from '@sanity/image-url'
import sanityClient from '@sanity/client'
function setUpSanity(isDraft = false) {
return sanityClient({
// Find your project ID and dataset in `sanity.json` in your studio project
projectId: process.env.SANITY_PROJECT_ID,
dataset: 'production',
@mornir
mornir / react.js
Last active June 8, 2019 12:41
React Component in Sanity editor
/**
* This is the schema definition for the rich text fields used for
* for this blog studio. When you import it in schemas.js it can be
* reused in other parts of the studio with:
* {
* name: 'someName',
* title: 'Some title',
* type: 'blockContent'
* }
*/