This file contains hidden or 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 {useState, useEffect, useCallback} from 'react' | |
import {useToast, Card, Button, Stack, Text, Code} from '@sanity/ui' | |
import {extractWithPath} from '@sanity/mutator' | |
import { | |
Preview, | |
DocumentActionProps, | |
SanityDocument, | |
useClient, | |
useSchema, | |
pathToString, |
This file contains hidden or 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 hidden or 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 {SlugSourceFn, SlugifierFn, defineField, defineType} from 'sanity' | |
import get from 'lodash/get' | |
// Fetch the category's slug – if present – and append the post's title | |
const handleSlugSource: SlugSourceFn = async (doc, context) => { | |
const categoryRef = get(doc, `category._ref`) | |
if (categoryRef) { | |
const client = context.getClient({apiVersion: `2023-07-01`}) | |
const categorySlug = await client.fetch(`*[_id == $id][0].slug.current`, {id: categoryRef}) |
This file contains hidden or 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, { useRef } from 'react' | |
import { map } from 'rxjs/operators' | |
import { createWeightedSearch } from 'part:@sanity/base/search/weighted' | |
import client from 'part:@sanity/base/client' | |
import ExternalReferenceInput from './ExternalReferenceInput' | |
const ExternalReference = props => { | |
const { type } = props | |
const { options } = type | |
const { dataset } = options |
This file contains hidden or 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/renameField.js` | |
// | |
// This example shows how you may write a migration script that sets all drafts to published version | |
// and deletes the draft version | |
// This will migrate documents in batches of 100 and continue patching until no more documents are | |
// returned from the query. | |
// |