- Disable Sanity CDN cache so published changes appear immediately - Add revalidate=60 to page so Next.js refreshes data every 60s - Wire AboutMe component to use siteSettings from Sanity (name, bio, photo, address, map coordinates) https://claude.ai/code/session_01H2aRGDaKgarPvhay2HxN6Y
22 lines
691 B
TypeScript
22 lines
691 B
TypeScript
import { createClient, type SanityClient } from "@sanity/client";
|
|
import imageUrlBuilder from "@sanity/image-url";
|
|
|
|
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID;
|
|
|
|
// Only create the real client if projectId is configured
|
|
export const sanityClient: SanityClient | null = projectId
|
|
? createClient({
|
|
projectId,
|
|
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET || "production",
|
|
apiVersion: "2024-01-01",
|
|
useCdn: false,
|
|
})
|
|
: null;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
export function urlFor(source: any) {
|
|
if (!sanityClient) return null;
|
|
const builder = imageUrlBuilder(sanityClient);
|
|
return builder.image(source);
|
|
}
|