Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): prepare nextjs starter template for live mode #7633

Merged
merged 5 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading