0c7217ba8f
## Feature - [x] Documentation added ## Documentation / Examples - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) This PR updates the cms-sanity example to: - Deploy to Vercel with the [Sanity Vercel Integration](https://www.sanity.io/docs/vercel-integration) by default. - You can still opt-out of using the Sanity Vercel Integration, clicking `You can also set up manually` gives you all the information you need. - The blog itself is updated so it's much more resilient to missing data, and is setup to set `revalidate: 60` until you have a On-demand Revalidation webhook setup. - Preview Mode is now enabled on the frontpage as well. - The Sanity client setup, and webhook validation, are updated to follow our current best practices.
15 lines
965 B
JavaScript
15 lines
965 B
JavaScript
export const sanityConfig = {
|
|
// Find your project ID and dataset in `sanity.json` in your studio project
|
|
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET || 'production',
|
|
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
|
|
useCdn:
|
|
typeof document !== 'undefined' && process.env.NODE_ENV === 'production',
|
|
// useCdn == true gives fast, cheap responses using a globally distributed cache.
|
|
// When in production the Sanity API is only queried on build-time, and on-demand when responding to webhooks.
|
|
// Thus the data need to be fresh and API response time is less important.
|
|
// When in development/working locally, it's more important to keep costs down as hot reloading can incurr a lot of API calls
|
|
// And every page load calls getStaticProps.
|
|
// To get the lowest latency, lowest cost, and latest data, use the Instant Preview mode
|
|
apiVersion: '2022-03-13',
|
|
// see https://www.sanity.io/docs/api-versioning for how versioning works
|
|
}
|