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
| const axios = require("axios"); | |
| const sanityClient = require('@sanity/client') | |
| const client = token => sanityClient({ | |
| projectId: '3do82whm', | |
| dataset: 'production', | |
| token | |
| }) | |
| const NPM_API_SEARCH = "https://api.npms.io/v2/search/suggestions" | |
| const NPM_API_PGKINFO = "https://api.npms.io/v2/package/" |
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. | |
| // |
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
| // Remember to add npm dependencies (click the 🔧) | |
| const SanityClient = require('@sanity/client'); | |
| const client = token => SanityClient({ | |
| projectId: '<YouProjectId>', | |
| dataset: 'production', | |
| useCdn: false, | |
| token | |
| }); | |
| module.exports = async function(context, cb) { |
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 PropTypes from 'prop-types' | |
| import React from 'react' | |
| import Fieldset from 'part:@sanity/components/fieldsets/default' | |
| import { PatchEvent, setIfMissing, set } from 'part:@sanity/form-builder/patch-event' | |
| import { FormBuilderInput } from 'part:@sanity/form-builder' | |
| import { render } from 'react-dom' | |
| import Downshift from 'downshift' | |
| export default class CustomObjectInput extends React.PureComponent { | |
| static propTypes = { |
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 */ | |
| const fs = require('fs') | |
| const sanityClient = require('@sanity/client') | |
| const groq = require('groq') | |
| const BlocksToMarkdown = require('@sanity/block-content-to-markdown') | |
| const config = { projectId: '<YourID>', dataset: '<DatasetName>', useCdn: true } | |
| const client = sanityClient(config) | |
| const serializers = { |
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 from 'react'; | |
| import getYouTubeID from 'get-youtube-id'; | |
| const YouTubePreview = ({ value }) => { | |
| const id = getYouTubeID(value.url); | |
| const url = `https://www.youtube.com/embed/${id}`; | |
| if (!id) { | |
| return <div>Missing YouTube URL</div>; | |
| } | |
| return ( |
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
| // Remember to add npm dependencies (click the 🔧) | |
| const SanityClient = require('@sanity/client'); | |
| const client = token => SanityClient({ | |
| projectId: '<YourProjectID>', | |
| dataset: 'production', | |
| useCdn: false, | |
| token | |
| }); | |
| module.exports = async function(context, cb) { |
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 PropTypes from 'prop-types' | |
| import React from 'react' | |
| import Fieldset from 'part:@sanity/components/fieldsets/default' | |
| import {setIfMissing} from 'part:@sanity/form-builder/patch-event' | |
| // FormBuilderInput automatically generates fields from a schema | |
| import {FormBuilderInput} from 'part:@sanity/form-builder' | |
| // a Higher Order Component that passes document values as props | |
| import {withDocument} from 'part:@sanity/form-builder' | |
| class CustomObjectInput extends React.PureComponent { |
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
| const { isFuture, format } = require('date-fns') | |
| async function createBlogPostPages(graphql, actions, reporter) { | |
| const { createPage, createPageDependency } = actions | |
| const result = await graphql(` | |
| { | |
| allSanityPost { | |
| edges { | |
| node { | |
| id |
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
| { | |
| "_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", |