mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This PR updates the `cms-sanity` example to use: - App Router - TypeScript - Sanity Studio v3 instead of v2 - Embeds the Studio inside the next app on the `/studio` route. - ISR / Data Cache (revalidations through `revalidatePath` while in Live Visual Editing, time-based to match the Sanity API CDN in production). - Support Vercel Visual Editing out of the box. - The new `next-sanity/image` component. - Vercel Speed Insights. - The Sanity Presentation Tool for live content previews. - Sanity Portable Text setup to fully support `@tailwindcss/typography`. - [AI Assist](https://www.sanity.io/docs/ai-assist) - Auto fill in `alt` text on images. - Preset prompts for content creation
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
/**
|
|
* As this file is reused in several other files, try to keep it lean and small.
|
|
* Importing other npm packages here could lead to needlessly increasing the client bundle size, or end up in a server-only function that don't need it.
|
|
*/
|
|
|
|
function assertValue<T>(v: T | undefined, errorMessage: string): T {
|
|
if (v === undefined) {
|
|
throw new Error(errorMessage);
|
|
}
|
|
|
|
return v;
|
|
}
|
|
|
|
export const dataset = assertValue(
|
|
process.env.NEXT_PUBLIC_SANITY_DATASET,
|
|
"Missing environment variable: NEXT_PUBLIC_SANITY_DATASET",
|
|
);
|
|
|
|
export const projectId = assertValue(
|
|
process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
|
|
"Missing environment variable: NEXT_PUBLIC_SANITY_PROJECT_ID",
|
|
);
|
|
|
|
/**
|
|
* see https://www.sanity.io/docs/api-versioning for how versioning works
|
|
*/
|
|
export const apiVersion =
|
|
process.env.NEXT_PUBLIC_SANITY_API_VERSION || "2024-02-28";
|
|
|
|
/**
|
|
* Used to configure edit intent links, for Presentation Mode, as well as to configure where the Studio is mounted in the router.
|
|
*/
|
|
export const studioUrl = "/studio";
|