feat(BOOK-57): Adjusted metadata for destination pages with active seo filter
Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
27
apps/scandic-web/utils/metadata/image/destinationPage.ts
Normal file
27
apps/scandic-web/utils/metadata/image/destinationPage.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { RawMetadataSchema } from "@scandic-hotels/trpc/routers/contentstack/metadata/output"
|
||||
|
||||
export function getDestinationFilterSeoMetaImage(data: RawMetadataSchema) {
|
||||
const filter = data.destinationData?.filter
|
||||
|
||||
if (!filter) {
|
||||
return null
|
||||
}
|
||||
|
||||
const foundSeoFilter = data.seo_filters?.find(
|
||||
(f) => f.filterConnection.edges[0]?.node?.slug === filter
|
||||
)
|
||||
|
||||
if (foundSeoFilter) {
|
||||
const metaDataImage = foundSeoFilter.seo_metadata?.seo_image
|
||||
if (metaDataImage) {
|
||||
return {
|
||||
url: metaDataImage.url,
|
||||
alt: metaDataImage.meta.alt || undefined,
|
||||
width: metaDataImage.dimensions.width,
|
||||
height: metaDataImage.dimensions.height,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user