svrjs-nextjs-website/lib/sanity.ts

18 lines
425 B
TypeScript
Raw Normal View History

2024-08-08 11:21:56 +02:00
import { createClient } from "next-sanity";
import imageUrlBuilder from "@sanity/image-url";
2024-08-08 19:23:56 +02:00
const config = {
apiVersion: "2023-08-08",
dataset: "production",
2024-09-07 14:59:43 +02:00
projectId: `${process.env.NEXT_PUBLIC_SANITY_PROJECT_ID}`,
useCdn: false // ensure fresh data
2024-08-08 19:23:56 +02:00
};
export const client = createClient(config);
2024-08-08 11:21:56 +02:00
const builder = imageUrlBuilder(client);
export function urlFor(source: any) {
return builder.image(source);
2024-08-08 11:21:56 +02:00
}