diff --git a/apps/scandic-web/utils/metadata/title.ts b/apps/scandic-web/utils/metadata/title.ts index ed22771de..e73ca580b 100644 --- a/apps/scandic-web/utils/metadata/title.ts +++ b/apps/scandic-web/utils/metadata/title.ts @@ -2,11 +2,26 @@ import { getIntl } from "@/i18n" import type { RawMetadataSchema } from "@scandic-hotels/trpc/routers/contentstack/metadata/output" +function getTitleSuffix(contentType: string) { + switch (contentType) { + case "content_page": + case "collection_page": + case "destination_overview_page": + case "destination_city_page": + case "destination_country_page": + return " | Scandic Hotels" + default: + return "" + } +} + export async function getTitle(data: RawMetadataSchema) { const intl = await getIntl() + const suffix = getTitleSuffix(data.system.content_type_uid) const metadata = data.web?.seo_metadata + if (metadata?.title) { - return metadata.title + return `${metadata.title}${suffix}` } if (data.system.content_type_uid === "hotel_page" && data.hotelData) { @@ -173,23 +188,25 @@ export async function getTitle(data: RawMetadataSchema) { ) } } - return intl.formatMessage( + const destinationTitle = intl.formatMessage( { defaultMessage: "Hotels in {location}", }, { location } ) + + return `${destinationTitle}${suffix}` } } } if (data.web?.breadcrumbs?.title) { - return data.web.breadcrumbs.title + return `${data.web.breadcrumbs.title}${suffix}` } if (data.heading) { - return data.heading + return `${data.heading}${suffix}` } if (data.header?.heading) { - return data.header.heading + return `${data.header.heading}${suffix}` } return "" }