feat(SW-201): Added hotel metadata

This commit is contained in:
Erik Tiekstra
2024-11-18 10:31:32 +01:00
parent a60c048476
commit 75c811eb32
5 changed files with 106 additions and 28 deletions
+15 -5
View File
@@ -1,7 +1,7 @@
import { z } from "zod"
import { tempImageVaultAssetSchema } from "../schemas/imageVault"
import { getDescription, getImages, getTitle } from "./utils"
import { getDescription, getImage, getTitle } from "./utils"
import type { Metadata } from "next"
@@ -71,16 +71,26 @@ export const rawMetadataSchema = z.object({
.nullable(),
hero_image: tempImageVaultAssetSchema.nullable(),
blocks: metaDataBlocksSchema,
hotel_page_id: z.string().optional().nullable(),
hotelData: z
.object({
name: z.string(),
city: z.string(),
description: z.string(),
image: z.object({ url: z.string(), alt: z.string() }).nullable(),
})
.optional()
.nullable(),
})
export const metadataSchema = rawMetadataSchema.transform((data) => {
export const metadataSchema = rawMetadataSchema.transform(async (data) => {
const noIndex = !!data.web?.seo_metadata?.noindex
const metadata: Metadata = {
title: getTitle(data),
description: getDescription(data),
title: await getTitle(data),
description: await getDescription(data),
openGraph: {
images: getImages(data),
images: getImage(data),
},
}