// lib/sanity.js

import { createClient } from '@sanity/client'
import imageUrlBuilder from '@sanity/image-url'

// Create a client configuration
const client = createClient({
  projectId: 'x3za3irm', // Replace with your project ID
  dataset: 'production', // Replace with your dataset name
  // apiVersion: '2024-01-01', // Use a date string in YYYY-MM-DD format
  useCdn: true, // Use the CDN for fast, cacheable responses
  token:
    'skH5k7iV4gwaAWJ45HVcESRsNIjRpmvTj76hBdcZa9e4C6OZyJz5GWHrjOid4Qhog7LtC5nTKykg8rbzdor0oGRoecbJ1IHgE4ceH8GZqTIBcCFFKuOTPZCNAamFBXLrTZK2v7HMMdtDGIfZX0SwblFPLneJket8cBuasE2XeG6pws5byCHY',
})

// Set up a helper function for generating image URLs
const builder = imageUrlBuilder(client)

export const urlFor = (source: any) => builder.image(source)

export default client
