-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UX-497 implement live preview framework * UX-497 properly set preview data on internal sanity preview * UX-497 add env variables to sanity studio (public facing, no sensitive data – honestly may not need these) * UX-497 use correct preview url on production * UX-497 Remove .env files * UX-497 update production & local urls * UX-497 remove unnecessary styled on outer box
- Loading branch information
1 parent
38634e9
commit def18d6
Showing
22 changed files
with
9,334 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
createClient, | ||
createImageUrlBuilder, | ||
createPreviewSubscriptionHook, | ||
createCurrentUserHook | ||
} from 'next-sanity'; | ||
|
||
const config = { | ||
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID, | ||
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET, | ||
apiVersion: '2021-03-25', | ||
useCdn: process.env.NODE_ENV === 'production' | ||
}; | ||
|
||
export const urlFor = (source) => createImageUrlBuilder(config).image(source); | ||
|
||
export const usePreviewSubscription = createPreviewSubscriptionHook(config); | ||
|
||
export const sanityClient = createClient(config); | ||
|
||
export const previewClient = createClient({ | ||
...config, | ||
useCdn: false, | ||
token: process.env.SANITY_API_TOKEN, | ||
withCredentials: true | ||
}); | ||
|
||
export const getClient = (usePreview) => (usePreview ? previewClient : sanityClient); | ||
|
||
export const useCurrentUser = createCurrentUserHook(config); |
Oops, something went wrong.