Skip to content

Commit

Permalink
feat(customerCase): main image
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Oct 17, 2024
1 parent 89fe792 commit d36c3d9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions studioShared/lib/interfaces/customerCases.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PortableTextBlock } from "sanity";

import { IImage } from "studio/lib/interfaces/media";

export interface CustomerCaseProjectInfo {
customer: string;
name: string;
Expand All @@ -18,6 +20,7 @@ export interface CustomerCaseBase {
}

export interface CustomerCase extends CustomerCaseBase {
image: IImage;
richText: PortableTextBlock[];
projectInfo: CustomerCaseProjectInfo;
}
11 changes: 9 additions & 2 deletions studioShared/lib/queries/customerCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,8 +44,7 @@ export const CUSTOMER_CASE_QUERY = groq`
},
_type == "imageBlock" => {
"images": images[] {
asset,
"alt": ${translatedFieldFragment("alt")}
${INTERNATIONALIZED_IMAGE_FRAGMENT}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions studioShared/schemas/documents/customerCase.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit d36c3d9

Please sign in to comment.