Skip to content

Instantly share code, notes, and snippets.

Congratulations! You've set up some basic scripts that allow you to deploy your website's code to the Vercel hosting platform.

Haven't installed anything yet? See the SETUP.md file here for instructions.

You should see three new .command files in your folder. You can click on these to perform actions:

  • preview-local.command: View your local changes in the browser. You can visit http://localhost:3000 in your browser. This command will continue to run in the terminal that opens. To exit, press Control+C, or close the Terminal pane. (You will see some warnings about a process still running - it is OK to close)
@good-idea
good-idea / sanity-block-content.d.ts
Created January 13, 2022 18:27
WIP sanity block content typings
// copied & modified from:
// https://github.com/nhi/sanity-block-content-to-react-types
declare module '@sanity/block-content-to-react' {
import * as React from 'react';
export interface Serializers {
/**
* Serializers for block types
* @example
@good-idea
good-idea / 01-InitialSetup.md
Last active October 21, 2021 21:29
OSS Workshop instructions
  1. Install Verdaccio - npm install --global verdaccio | yarn global add verdaccio
  2. Register an account and organization at npmjs.com. The org can be your github handle, or anything else you'd like. The org will be the "scope" for your package, i.e. @my-org/my-package
  3. Install [asdf](http://asdf-vm.com/guide/getting-started.html#_3-install-asdf) then run asdf install nodejs 14.17.6
@good-idea
good-idea / gist:46d01e3d657aa3de4cc004be61bd73c5
Created October 5, 2021 16:20
swell-sanity-homepage-query-explain
.
└── Evaluate expr: ([0])
│ legacyArraySemantics: true
└── Map expr: ({
│ ...,
│ \"body\": body[].<LegacyScope expr={
│ ...,
│ \"asset\": asset._ref.<LegacySingleKeyJoin source=___refJoin_2 keyExpr=_id>.<LegacyScope expr={
│ \"_id\": _id,
│ \"extension\": extension,
@good-idea
good-idea / pages_product.tsx
Last active October 5, 2021 20:04
SK Refetch hook
// all the existing imports..
import { useRefetch } from '../src/hooks'
const productQuery = gql`
...
`
interface Response {
allShopifyProduct: ShopifyProduct[]
@good-idea
good-idea / RatioPadding.tsx
Last active July 29, 2021 23:34
React SanityImage Component
import * as React from 'react';
import { RatioImageFill } from './styled';
interface RatioPaddingProps {
ratio: number;
canvasFill?: boolean;
backgroundColor?: string;
}
export const RatioPadding = ({
import {
Article,
ArticleGroup,
Homepage,
Topic,
Model,
GlossaryTerm,
ObjectScalarProperty,
Steps,
Step,
@good-idea
good-idea / GetArticleImage.tsx
Created March 12, 2021 18:54
Sanity Related Select
import * as React from 'react';
import { SanityDocument } from '@sanity/client';
import { withDocument } from 'part:@sanity/form-builder';
import { Stack, Select, Heading, Button, Text } from '@sanity/ui';
import { useDocumentOperation } from '@sanity/react-hooks';
import createImageUrlBuilder from '@sanity/image-url';
import client from '../utils/client';
import { definitely } from '../utils/definitely';
@good-idea
good-idea / 0-readme.md
Last active March 29, 2023 21:00
SWR Lazy Hook

A simple hook to create a "lazy request" hook using swr.

! This isn't perfect !

The problem with the example below is that you need to know your variables when you call useLazyRequest. This might not work in all situations, for instance, if your component is getting the variables from state that might change. This could be fixed by putting the call to useLazyRequest within a child component that receives those variables as props.

See the typescript example below.

Not fully tested, I just wrote this on the fly. If you have any suggestions, please add them in a comment!

@good-idea
good-idea / removeSaneShopifyDocuments.js
Created February 9, 2020 17:21
Remove all shopifyProducts and shopifyCollections from sanity dataset
/**
WARNING: THIS DELETES DATA
Run this within your Sanity project directory with:
yarn sanity exec --with-user-token removeSaneShopifyDocuments.js
**/