This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CustomNumberSelect from './customNumberSelect' | |
export default { | |
name: 'sizes', | |
type: 'number', | |
inputComponent: CustomNumber, | |
options: { | |
list: [ | |
{title: 'xsmall', value: 1}, | |
{title: 'small', value: 2}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load variables from `.env` as soon as possible | |
require('dotenv').config({ | |
path: `.env.${process.env.NODE_ENV || 'development'}` | |
}) | |
const fetch = require('isomorphic-fetch') | |
const { createHttpLink } = require('apollo-link-http') | |
const PortableText = require('@sanity/block-content-to-html') | |
const imageUrlBuilder = require('@sanity/image-url') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sanityClient = require('@sanity/client') | |
const reduce = require('json-reduce').default | |
const Translate = require('@google-cloud/translate') | |
const DATASET = 'production' | |
const SUPPORTED_LANGUAGES = [ | |
{id: 'en', title: 'English', isDefault: true, googleTranslateCode: 'en'}, | |
{id: 'de', title: 'German (Deutsch)', googleTranslateCode: 'de'}, | |
{id: 'jp', title: 'Japanese (日本語)', googleTranslateCode: 'ja'} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, Fragment } from 'react' | |
import { BlockEditor } from 'part:@sanity/form-builder' | |
import Switch from 'part:@sanity/components/toggles/switch' | |
import css from './BlockEditor.module.css' | |
import { handlePaste } from './handlePaste' | |
export default class CustomEditor extends Component { | |
state = { | |
customPaste: false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script context="module"> | |
import blocksToHtml from '@sanity/block-content-to-html' | |
import urlBuilder from '@sanity/image-url' | |
import client from '../../sanityClient' | |
import serializers from '../../components/serializers' | |
const urlFor = source => urlBuilder(client).image(source); | |
export async function preload({ params }) { | |
// the `slug` parameter is available because |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* CUSTOM SANITY STUDIO INPUT COMPONENT FOR FONT-AWESOME | |
* | |
* This is a proof of concept custom input component that loads the whole free library of font awesome icons and makes them | |
* searchable in a downshift component. If they're selected the font name will be saved as a string on the document. | |
* | |
* Install dependencies in your studio folder with: | |
* yarn add @fortawesome/fontawesome-svg-core @fortawesome/react-fontawesome @fortawesome/free-solid-svg-icons downshift | |
* | |
* Use as a custom input component in your shcema: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// require some file system methods | |
const fs = require('fs') | |
(() => { | |
// read the file with the lyrics++ | |
const lyrics = fs.readFileSync('./lyrics.txt', 'utf-8') | |
// clean out things we don't want | |
const withoutChordsAndStuff = lyrics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const editJsonFile = require('edit-json-file'); | |
const stylePath = 'part:@sanity/base/theme/variables/override-style'; | |
const folder = `${__dirname}/studio/`; | |
const file = editJsonFile(`${folder}sanity.json`); | |
const prepareFile = ({ ENVIRONMENT, BRAND }) => { | |
const parts = file.get('parts'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_createdAt": "2019-05-27T07:27:48Z", | |
"_id": "06b92a73-8502-45e8-ab8e-31b76181cf94", | |
"_rev": "CCW6uuhzMbOOH3oXLDotsE", | |
"_type": "post", | |
"_updatedAt": "2019-06-01T08:33:03Z", | |
"authors": [ | |
{ | |
"_key": "02bcfae524e0", | |
"_ref": "14165126-a0fd-4e5e-96af-686d36f408e0", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { isFuture, format } = require('date-fns') | |
async function createBlogPostPages(graphql, actions, reporter) { | |
const { createPage, createPageDependency } = actions | |
const result = await graphql(` | |
{ | |
allSanityPost { | |
edges { | |
node { | |
id |