756b365adf
* Add start of Sanity CMS example * Update cover-image * Clean up example * Apply suggestions from code review Co-Authored-By: Shu Uesugi <shu@chibicode.com> * Make changes from review * Remove extra style * Apply suggestions from code review Co-Authored-By: Shu Uesugi <shu@chibicode.com> * Make tweaks for preview mode and normalize env naming * Update viewing preview step * Delete author.jpg * Delete image.jpg * Update README * Fix environment variable names * Project ID is needed by lambda * Improved steps * Fixed issue with the project URL example * Clarify line * Get the preview post correctly * preview = false * Get unique posts * Show preview mode on index page * typo fix and use next latest * Added related examples section Co-authored-by: Shu Uesugi <shu@chibicode.com> Co-authored-by: Luis Alvarez <luis@zeit.co>
18 lines
678 B
JavaScript
18 lines
678 B
JavaScript
import sanityClient from '@sanity/client'
|
|
|
|
const options = {
|
|
// Find your project ID and dataset in `sanity.json` in your studio project
|
|
dataset: 'production',
|
|
projectId: process.env.NEXT_EXAMPLE_CMS_SANITY_PROJECT_ID,
|
|
useCdn: process.env.NODE_ENV === 'production',
|
|
// useCdn == true gives fast, cheap responses using a globally distributed cache.
|
|
// Set this to false if your application require the freshest possible
|
|
// data always (potentially slightly slower and a bit more expensive).
|
|
}
|
|
|
|
export default sanityClient(options)
|
|
export const previewClient = sanityClient({
|
|
...options,
|
|
useCdn: false,
|
|
token: process.env.NEXT_EXAMPLE_CMS_SANITY_API_TOKEN,
|
|
})
|