-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity.js
21 lines (19 loc) · 827 Bytes
/
sanity.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {
createClient,
createCurrentUserHook,
createImageUrlBuilder,
} from "next-sanity";
import imageUrlBuilder from "@sanity/image-url";
//configure the backend
export const config = {
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID, // you can find this in sanity.json
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET, // or the name you chose in step 1
apiVersion: "2021-10-21", // use a UTC date string
useCdn: true, // `false` if you want to ensure fresh data
};
//setup clients for fetching data in the getProps page funcion
export const sanityClient = createClient(config);
//genarating the Image url
export const urlFor = (source) => imageUrlBuilder(config).image(source);
//Helper function for usign the current logged in user account
export const useCurrentUser = createCurrentUserHook(config);