From 94b33abd2e40be1be989a8a4810a04d497976ea8 Mon Sep 17 00:00:00 2001 From: Callum Bonnyman Date: Fri, 23 Jun 2023 11:46:08 +0545 Subject: [PATCH] Removed un-used sanityClient. (#158) --- src/lib/sanityClient.ts | 30 ------------------------------ src/lib/sanityImage.ts | 2 +- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 src/lib/sanityClient.ts diff --git a/src/lib/sanityClient.ts b/src/lib/sanityClient.ts deleted file mode 100644 index c9a0f06..0000000 --- a/src/lib/sanityClient.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { createClient, groq } from 'next-sanity'; - -export const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID || ''; -export const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET || ''; -export const apiVersion = process.env.NEXT_PUBLIC_SANITY_API_VERSION; - -export const client = createClient({ - projectId, - dataset, - apiVersion, - useCdn: typeof document !== 'undefined', -}); - -export const getDocumentSlugs = async (documentType: string) => - await client.fetch( - groq`*[_type == $documentType][] { "slug": slug.current }`, - { documentType } - ); - -export const getDocumentMeta = async ( - slug: string, - additionalData: string = '' -): Promise<{ - seo: MetaData; - additionalData: T; -}> => { - const query = groq`*[slug.current == $slug][0] { seo, ${additionalData} }`; - const { seo, ...data } = await client.fetch(query, { slug }); - return { seo, additionalData: data }; -}; diff --git a/src/lib/sanityImage.ts b/src/lib/sanityImage.ts index 3a6755b..eb2ae89 100644 --- a/src/lib/sanityImage.ts +++ b/src/lib/sanityImage.ts @@ -1,7 +1,7 @@ import createImageUrlBuilder from '@sanity/image-url'; import { ImageProps } from 'next/image'; -import { dataset, projectId } from '~/lib/sanityClient'; +import { dataset, projectId } from '~/sanity/env'; const imageBuilder = createImageUrlBuilder({ projectId, dataset });