Skip to content

Commit

Permalink
feat(cli): prepare nextjs starter template for live mode (#7633)
Browse files Browse the repository at this point in the history
Co-authored-by: Espen Hovlandsdal <[email protected]>
  • Loading branch information
2 people authored and jordanl17 committed Nov 5, 2024
1 parent 2bdccbd commit a1c1775
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@ export const client = createClient({
})
`

const live = `// 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'
})
});
`

const imageTS = `import createImageUrlBuilder from '@sanity/image-url'
import { SanityImageSource } from "@sanity/image-url/lib/types/types";
Expand Down Expand Up @@ -201,6 +216,7 @@ export const sanityFolder = (
'env.': useTypeScript ? envTS : envJS,
'lib': {
'client.': client,
'live.': live,
'image.': useTypeScript ? imageTS : imageJS,
},
}
Expand Down

0 comments on commit a1c1775

Please sign in to comment.