Skip to content

Instantly share code, notes, and snippets.

@3200pro
3200pro / figure.js
Created July 12, 2020 23:00
Sanity CMS Figure Schema
export default {
name: "figure",
title: "Image",
type: "image",
options: {
hotspot: true,
},
fields: [
{
title: "Caption",
@3200pro
3200pro / Figure.js
Last active February 9, 2021 22:52
Figure Ternary Setup For Gatsby & Sanity
import React from 'react'
import { getFluidGatsbyImage } from 'gatsby-source-sanity'
import Img from 'gatsby-image'
import { buildImageObj } from '../../lib/helpers'
import { imageUrlFor } from '../../lib/image-url'
import clientConfig from '../../../client-config'
function Figure(props) {
const data = props
@3200pro
3200pro / DarkModeImages.js
Last active July 19, 2020 20:58
Gatsby +Sanity: Darkmode image that allow alternate image (Sanity Schema Code)
/** @jsx jsx */
import { jsx, useColorMode } from "theme-ui"
import { buildImageObj } from '../../lib/helpers'
import { imageUrlFor } from '../../lib/image-url'
function DarkModeImage (props) {
const [colorMode] = useColorMode()
const SanityImageToggle = (colorMode == 'light') ? props.primaryImage : props.darkmodeImage
return (
<figure>
@3200pro
3200pro / DarkModeImage.js
Created July 19, 2020 21:00
Gatsby +Sanity: Darkmode image that allow alternate image (Gatsby Component)
/** @jsx jsx */
import { jsx, useColorMode } from "theme-ui"
import { buildImageObj } from '../../lib/helpers'
import { imageUrlFor } from '../../lib/image-url'
function DarkModeImages (props) {
const [colorMode] = useColorMode()
const SanityImageToggle = (colorMode == 'light') ? props.primaryImage : props.darkmodeImage
return (
<figure>
@3200pro
3200pro / shuffleTextBlock.js
Created November 29, 2020 03:14
Sanity Schema - Shuffled Text - Part 1
export default {
title: 'Shuffle Text Block',
name: 'shuffleTextBlock',
type: 'object',
description: 'Create mixture of shuffle text and normal text',
fields: [
{
title: 'Text Section',
name: 'textSection',
type: 'array',
@3200pro
3200pro / shuffledTextSection.js
Created November 29, 2020 03:19
Sanity Schema - Shuffled Text - Part 2
export default {
title: 'Shuffled Text Section',
name: 'shuffledTextSection',
type: 'object',
fields: [
{
title: 'Phrase',
type: 'array',
name: 'phrase',
of: [
@3200pro
3200pro / standardText.js
Last active November 29, 2020 22:05
Sanity Schema - Shuffled Text - Part 4
export default {
title: 'Text',
name: 'standardText',
type: 'object',
fields: [
{
title: 'String',
name: 'string',
type: 'string'
},
@3200pro
3200pro / shuffledText.js
Last active November 29, 2020 22:04
Sanity Schema - Shuffled Text - Part 3
export default {
title: 'Shuffled Text',
type: 'object',
name: 'shuffledText',
fields: [
{
title: 'Shuffled Text',
name: 'text',
type: 'array',
of: [
@3200pro
3200pro / ShuffleText.js
Created November 29, 2020 13:34
Sanity Schema - Shuffled Text - Part 5 Gatsby Integration
/** @jsx jsx */
import { jsx } from "theme-ui"
import React, { useState } from 'react'
import TextScramble from './textShuffleMaster'
function ShuffleText (props) {
const Style = props.textSection[0].textStyle ? props.textSection[0].textStyle: 'span'
const ShuffleText = props.textSection && props.textSection[0].phrase
const [pause] = useState(false)
return (
@3200pro
3200pro / sanity-io-delete-posts.cli
Last active December 26, 2020 21:36
Sanity.io Delete Posts
curl 'https://<Project ID>.api.sanity.io/v1/data/mutate/production' \
-H 'Authorization: Bearer <Token>' \
-H 'Content-Type: application/json' \
--data-binary '{"mutations":[
{
"delete": {
"id": "<Post ID>"
}
}
]}'