From eb90c382b85dbc98258cd7092010bbd91160646d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20J=C3=A4derberg?= Date: Thu, 11 Dec 2025 12:51:36 +0000 Subject: [PATCH] Merged in fix/remove-scandic-friends-robots-override (pull request #3322) fix: remove /scandic-friends indexable override * fix: remove /scandic-friends indexable override Approved-by: Bianca Widstam Approved-by: Anton Gunnarsson --- .../utils/metadata/generateMetadata.ts | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/apps/scandic-web/utils/metadata/generateMetadata.ts b/apps/scandic-web/utils/metadata/generateMetadata.ts index d5ed71b63..f5964aaf4 100644 --- a/apps/scandic-web/utils/metadata/generateMetadata.ts +++ b/apps/scandic-web/utils/metadata/generateMetadata.ts @@ -9,7 +9,6 @@ import { getImage } from "./image" import { getTitle } from "./title" import type { Metadata } from "next" -import type { AlternateURLs } from "next/dist/lib/metadata/types/alternative-urls-types" export async function generateMetadata({ searchParams, @@ -48,51 +47,12 @@ export async function generateMetadata({ ...metadata, robots: { ...metadata.robots, - index: isIndexable(metadata.robots?.index, alternates), - follow: isIndexable(metadata.robots?.follow, alternates), + index: metadata.robots?.index ?? true, + follow: metadata.robots?.follow ?? true, }, } } -function isIndexable( - pageIndexableFromSettings: boolean | null | undefined, - alternates: AlternateURLs | null -) { - // This is a special case for whitelisting the scandic friends pages, this can be removed when all pages are live - const url = getUrl(alternates) - const firstNonLangSegment = (url ?? "").substring(3) - if (firstNonLangSegment.startsWith("/scandic-friends")) { - return true - } - - // If we are live we want to index the page, but if the page has been marked as noindex in contentstack we don't - return pageIndexableFromSettings ?? true -} - -function getUrl(alternates: AlternateURLs | null): string | null { - try { - if (!alternates?.canonical) { - return null - } - - if (typeof alternates.canonical === "string") { - return alternates.canonical - } - - if ("href" in alternates.canonical) { - return alternates.canonical.href - } - - if (typeof alternates.canonical.url === "string") { - return alternates.canonical.url - } - - return alternates.canonical.url.href - } catch { - return null - } -} - function isNoIndexFromMetadata(data: RawMetadataSchema) { const isDestinationPage = [ PageContentTypeEnum.destinationCityPage,