diff --git a/src/app/(main)/[lang]/[...path]/page.tsx b/src/app/(main)/[lang]/[...path]/page.tsx index d727d8995..fcf222f5f 100644 --- a/src/app/(main)/[lang]/[...path]/page.tsx +++ b/src/app/(main)/[lang]/[...path]/page.tsx @@ -30,8 +30,7 @@ function seoDataFromPageData( // TODO return null; case "customerCasesPage": - // TODO - return null; + return data.queryResponse.data.seo; case "pageBuilder": // TODO return null; diff --git a/src/components/customerCases/CustomerCases.tsx b/src/components/customerCases/CustomerCases.tsx index 167ffeccb..fec733a4a 100644 --- a/src/components/customerCases/CustomerCases.tsx +++ b/src/components/customerCases/CustomerCases.tsx @@ -20,9 +20,9 @@ const CustomerCases = async ({ customerCasesPage }: CustomerCasesProps) => { const [sharedCustomerCases] = await Promise.all([ loadSharedQuery( CUSTOMER_CASES_QUERY, - { language: "en" }, + { language: customerCasesPage.language }, { perspective }, - ), //TODO: Replace hard coded language with selected language + ), ]); return ( diff --git a/src/utils/pageData.ts b/src/utils/pageData.ts index f7c66825e..7d3fdbb2d 100644 --- a/src/utils/pageData.ts +++ b/src/utils/pageData.ts @@ -149,6 +149,7 @@ async function fetchCustomerCase({ } const customerCasesPageParams = { slug: path[0], + language, }; const customerCasesPageResult = await loadStudioQuery( diff --git a/studio/lib/interfaces/specialPages.ts b/studio/lib/interfaces/specialPages.ts index f94e85a28..eb32e0496 100644 --- a/studio/lib/interfaces/specialPages.ts +++ b/studio/lib/interfaces/specialPages.ts @@ -1,3 +1,5 @@ +import { SeoData } from "src/utils/seo"; + import { Slug } from "./global"; export interface CustomerCasePage { @@ -9,4 +11,6 @@ export interface CustomerCasePage { basicTitle: string; page: string; slug: Slug; + language: string; + seo: SeoData; } diff --git a/studio/lib/queries/specialPages.ts b/studio/lib/queries/specialPages.ts index e58ec2d2d..c1269ef08 100644 --- a/studio/lib/queries/specialPages.ts +++ b/studio/lib/queries/specialPages.ts @@ -34,7 +34,18 @@ export const COMPENSATIONS_PAGE_SITEMAP_QUERY = groq` //Customer Cases export const CUSTOMER_CASES_PAGE_QUERY = groq` - *[_type == "customerCasesPage" && slug.current == $slug][0]`; + *[_type == "customerCasesPage" && ${translatedFieldFragment("slug")} == $slug][0]{ + ..., + "language": $language, + "slug": ${translatedFieldFragment("slug")}, + "basicTitle": ${translatedFieldFragment("basicTitle")}, + "seo": ${translatedFieldFragment("seo")} { + "title": seoTitle, + "description": seoDescription, + "imageUrl": seoImage.asset->url, + "keywords": seoKeywords + }, + }`; export const CUSTOMER_CASES_PAGE_SITEMAP_QUERY = groq` *[_type == "customerCasesPage"][0] { diff --git a/studio/schemas/documents/specialPages/customerCasesPage.ts b/studio/schemas/documents/specialPages/customerCasesPage.ts index 8d17f527d..483fad2c1 100644 --- a/studio/schemas/documents/specialPages/customerCasesPage.ts +++ b/studio/schemas/documents/specialPages/customerCasesPage.ts @@ -1,8 +1,9 @@ import { defineType } from "sanity"; -import { title } from "studio/schemas/fields/text"; -import seo from "studio/schemas/objects/seo"; +import { isInternationalizedString } from "studio/lib/interfaces/global"; +import { titleID } from "studio/schemas/fields/text"; import { titleSlug } from "studio/schemas/schemaTypes/slug"; +import { firstTranslation } from "studio/utils/i18n"; export const customerCasesPageID = "customerCasesPage"; @@ -12,17 +13,34 @@ const customerCasesPage = defineType({ title: "Customer Cases", fields: [ { - ...title, + name: titleID.basic, + type: "internationalizedArrayString", title: "Customer Case Page Title", description: "Enter the primary title that will be displayed at the top of the customer cases page. This is what users will see when they visit the page.", }, - titleSlug, - seo, + { + ...titleSlug, + type: "internationalizedArrayString", + }, + { + name: "seo", + type: "internationalizedArraySeo", + }, ], preview: { select: { - title: "basicTitle", + title: titleID.basic, + }, + prepare({ title }) { + if (!isInternationalizedString(title)) { + throw new TypeError( + `Expected 'title' to be InternationalizedString, was ${typeof title}`, + ); + } + return { + title: firstTranslation(title) ?? undefined, + }; }, }, });