feat(BOOK-57): Adjusted metadata for destination pages with active seo filter

Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
Erik Tiekstra
2025-09-25 13:26:00 +00:00
parent 7714761c77
commit 9f02870647
20 changed files with 678 additions and 458 deletions

View File

@@ -1,3 +1,4 @@
import { PageContentTypeEnum } from "@scandic-hotels/trpc/enums/contentType"
import { type RawMetadataSchema } from "@scandic-hotels/trpc/routers/contentstack/metadata/output"
import { env } from "@/env/server"
@@ -99,13 +100,33 @@ function getUrl(alternates: AlternateURLs | null): string | null {
}
}
function isNoIndexFromMetadata(data: RawMetadataSchema) {
const isDestinationPage = [
PageContentTypeEnum.destinationCityPage,
PageContentTypeEnum.destinationCountryPage,
].includes(data.system.content_type_uid as PageContentTypeEnum)
if (isDestinationPage) {
const filter = data.destinationData?.filter
if (filter) {
const foundSeoFilter = data.seo_filters?.find(
(f) => f.filterConnection.edges[0]?.node?.slug === filter
)
if (foundSeoFilter) {
return !!foundSeoFilter.seo_metadata?.noindex
}
}
}
return !!data.web?.seo_metadata?.noindex
}
async function getTransformedMetadata(
data: RawMetadataSchema,
alternates: Metadata["alternates"] | null,
robots: Metadata["robots"] | null = null
) {
const noIndex = !!data.web?.seo_metadata?.noindex
const metadata: Metadata = {
metadataBase: env.PUBLIC_URL ? new URL(env.PUBLIC_URL) : undefined,
title: await getTitle(data),
@@ -117,7 +138,7 @@ async function getTransformedMetadata(
robots,
}
if (noIndex) {
if (isNoIndexFromMetadata(data)) {
metadata.robots = {
index: false,
follow: false,