From d36c3d914e468a3f9a0171460cad0a907afd3c5e Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Thu, 17 Oct 2024 12:18:05 +0200 Subject: [PATCH] feat(customerCase): main image --- studioShared/lib/interfaces/customerCases.ts | 3 +++ studioShared/lib/queries/customerCases.ts | 11 +++++++++-- studioShared/schemas/documents/customerCase.ts | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/studioShared/lib/interfaces/customerCases.ts b/studioShared/lib/interfaces/customerCases.ts index 982ebf5c1..431796f47 100644 --- a/studioShared/lib/interfaces/customerCases.ts +++ b/studioShared/lib/interfaces/customerCases.ts @@ -1,5 +1,7 @@ import { PortableTextBlock } from "sanity"; +import { IImage } from "studio/lib/interfaces/media"; + export interface CustomerCaseProjectInfo { customer: string; name: string; @@ -18,6 +20,7 @@ export interface CustomerCaseBase { } export interface CustomerCase extends CustomerCaseBase { + image: IImage; richText: PortableTextBlock[]; projectInfo: CustomerCaseProjectInfo; } diff --git a/studioShared/lib/queries/customerCases.ts b/studioShared/lib/queries/customerCases.ts index b4f71bdc0..98ab66bbf 100644 --- a/studioShared/lib/queries/customerCases.ts +++ b/studioShared/lib/queries/customerCases.ts @@ -17,9 +17,17 @@ export const CUSTOMER_CASES_QUERY = groq` } `; +const INTERNATIONALIZED_IMAGE_FRAGMENT = groq` + asset, + "alt": ${translatedFieldFragment("alt")} +`; + export const CUSTOMER_CASE_QUERY = groq` *[_type == "customerCase" && ${translatedFieldFragment("slug")} == $slug][0] { ${CUSTOMER_CASE_BASE_FRAGMENT}, + "image": image { + ${INTERNATIONALIZED_IMAGE_FRAGMENT} + }, "richText": ${translatedFieldFragment("richText")}, "projectInfo": projectInfo { customer, @@ -36,8 +44,7 @@ export const CUSTOMER_CASE_QUERY = groq` }, _type == "imageBlock" => { "images": images[] { - asset, - "alt": ${translatedFieldFragment("alt")} + ${INTERNATIONALIZED_IMAGE_FRAGMENT} } } } diff --git a/studioShared/schemas/documents/customerCase.ts b/studioShared/schemas/documents/customerCase.ts index 6cf08f1e7..4e2c84c5f 100644 --- a/studioShared/schemas/documents/customerCase.ts +++ b/studioShared/schemas/documents/customerCase.ts @@ -1,6 +1,7 @@ import { defineField, defineType } from "sanity"; import { isInternationalizedString } from "studio/lib/interfaces/global"; +import { internationalizedImage } from "studio/schemas/fields/media"; import { richTextID, titleID } from "studio/schemas/fields/text"; import { titleSlug } from "studio/schemas/schemaTypes/slug"; import { firstTranslation } from "studio/utils/i18n"; @@ -31,6 +32,11 @@ const customerCase = defineType({ description: "Short paragraph displayed at the top of the customer case page", }), + defineField({ + ...internationalizedImage, + title: "Main Image", + description: "Large image displayed at the top of the customer case page", + }), defineField({ ...customerCaseProjectInfo, options: {