-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsanity.js
21 lines (17 loc) · 817 Bytes
/
sanity.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// prefer javascript file
import createImageUrlBuilder from "@sanity/image-url";
import { createClient } from "next-sanity";
export const config = {
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET || "production",
token: process.env.SANITY_API_TOKEN,
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
apiVersion: "2022-10-15", // Learn more https://www.sanity.io/docs/api-versioning
useCdn: process.env.NODE_ENV === "production",
};
// Set up the client for fetching data in the getProps page function
export const sanityClient = createClient(config);
/**
* Set up a helper function for generating Image URLs with only the asset reference data in your documents.
* Read more: https://www.sanity.io/docs/image-url
**/
export const urlFor = (source) => createImageUrlBuilder(config).image(source);