svrjs-nextjs-website/lib/sanity.ts

18 lines
409 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",
2024-08-08 11:21:56 +02:00
dataset: "production",
projectId: `${process.env.SANITY_PROJECT_ID}`,
2024-08-08 19:23:56 +02:00
useCdn: false, // ensure fresh data
};
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);
}