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
/** | |
* Retroactively add Blurhash strings to image assets in your Sanity Content Lake. | |
* 1. yarn add got sharp blurhash | |
* 2. run sanity exec blurhash --with-user-token | |
* 3. repeat (patches 100 assets in 1 transaction pr run) | |
* | |
* Some images might take a while to process. | |
*/ | |
import client from 'part:@sanity/base/client' | |
import got from 'got' |
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 blockTools = require("@sanity/block-tools").default; | |
const jsdom = require("jsdom"); | |
const { JSDOM } = jsdom; | |
const HTML_SPAN_TAGS = { | |
span: {object: 'text'}, | |
} | |
const defaultSchema = require("./defaultSchema"); | |
function tagName(el) { |
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
<html> | |
<head> | |
<title>No JS please</title> | |
</head> | |
<body> | |
<main> | |
<noscript> | |
Content! | |
<style> |
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, { useState, forwardRef, Fragment } from 'react' | |
import { BlockEditor } from 'part:@sanity/form-builder' | |
import Switch from 'part:@sanity/components/toggles/switch' | |
import css from './PTeditor.module.css' | |
import { handlePaste } from './handlePaste' | |
function CustomEditor(props, ref){ | |
const [customPaste, setCustomPaste] = useState(false) | |
function handleCustomPaste () { |
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 from "react"; | |
import Img from "gatsby-image"; | |
import { getFluidGatsbyImage } from "gatsby-source-sanity"; | |
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; | |
import { atomDark } from "react-syntax-highlighter/dist/esm/styles/prism"; | |
import iconLinksList from "./iconLinksList.js"; | |
import YouTube from "../components/YouTube.js"; | |
import getYouTubeID from "get-youtube-id"; | |
const sanityConfig = { projectId: "rx426fbd", dataset: "production" }; |
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 'part:@sanity/base/theme/variables-style'; | |
.item { | |
padding: var(--small-padding); | |
} | |
.searchableSelect { | |
composes: spacing from 'part:@sanity/components/buttons/default-style'; | |
grid-column: span 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
/* eslint-disable no-console */ | |
import client from 'part:@sanity/base/client' | |
// Run this script with: `sanity exec --with-user-token migrations/migrateValues.js` | |
// | |
// This example shows how you may write a migration script that migrates a field value | |
// on a specific document type. | |
// This will migrate documents in batches of 100 and continue patching until no more documents are | |
// returned from the query. | |
// |
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
// Example of how to output this in a React frontend | |
import React from 'react' | |
import BlockContent from '@sanity/block-content-to-react' | |
import { TwitterTweetEmbed } from 'react-twitter-embed' | |
const Tweet = ({url}) => { | |
const exp = /\/status\/(\d+)($|[?/])/ | |
const [, id] = exp.exec(url) || [] | |
if (id) { | |
return <TwitterTweetEmbed className="sliderBoxes" tweetId={id} options={{conversation: 'none', 'hide-thread': true}} /> |
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.js | |
* | |
* Install dependencies: | |
* yarn add p-queue nanoid | |
* or | |
* npm i p-queue nanoid && sanity install | |
* | |
* Run this script with: | |
* sanity exec --with-user-token import.js |