edit
This commit is contained in:
10
sanity/lib/client.ts
Normal file
10
sanity/lib/client.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createClient } from 'next-sanity'
|
||||
|
||||
import { apiVersion, dataset, projectId } from '../env'
|
||||
|
||||
export const client = createClient({
|
||||
projectId,
|
||||
dataset,
|
||||
apiVersion,
|
||||
useCdn: true, // Set to false if statically generating pages, using ISR or tag-based revalidation
|
||||
})
|
11
sanity/lib/image.ts
Normal file
11
sanity/lib/image.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import createImageUrlBuilder from '@sanity/image-url'
|
||||
import { SanityImageSource } from "@sanity/image-url/lib/types/types";
|
||||
|
||||
import { dataset, projectId } from '../env'
|
||||
|
||||
// https://www.sanity.io/docs/image-url
|
||||
const builder = createImageUrlBuilder({ projectId, dataset })
|
||||
|
||||
export const urlFor = (source: SanityImageSource) => {
|
||||
return builder.image(source)
|
||||
}
|
13
sanity/lib/live.ts
Normal file
13
sanity/lib/live.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// Querying with "sanityFetch" will keep content automatically updated
|
||||
// Before using it, import and render "<SanityLive />" in your layout, see
|
||||
// https://github.com/sanity-io/next-sanity#live-content-api for more information.
|
||||
import { defineLive } from "next-sanity";
|
||||
import { client } from './client'
|
||||
|
||||
export const { sanityFetch, SanityLive } = defineLive({
|
||||
client: client.withConfig({
|
||||
// Live content is currently only available on the experimental API
|
||||
// https://www.sanity.io/docs/api-versioning
|
||||
apiVersion: 'vX'
|
||||
})
|
||||
});
|
Reference in New Issue
Block a user