svrjs-nextjs-website/lib/sanity.ts
2024-08-08 22:53:56 +05:30

17 lines
409 B
TypeScript

import { createClient } from "next-sanity";
import imageUrlBuilder from "@sanity/image-url";
const config = {
apiVersion: "2023-08-08",
dataset: "production",
projectId: `${process.env.SANITY_PROJECT_ID}`,
useCdn: false, // ensure fresh data
};
export const client = createClient(config);
const builder = imageUrlBuilder(client);
export function urlFor(source: any) {
return builder.image(source);
}