feat(SW-2408): Improved meta titles for Hotel subpages

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-05-27 05:32:50 +00:00
parent a849c48edd
commit 8b85235f1d

View File

@@ -15,7 +15,7 @@ export async function getTitle(data: RawMetadataSchema) {
(restaurant) => restaurant.nameInUrl === data.subpageUrl
)
if (restaurantSubPage) {
return intl.formatMessage(
const restaurantTitleLong = intl.formatMessage(
{
defaultMessage:
"Explore {restaurantName} at {hotelName} in {destination}",
@@ -26,11 +26,44 @@ export async function getTitle(data: RawMetadataSchema) {
destination: data.hotelData.address.city,
}
)
const restaurantTitleShort = intl.formatMessage(
{
defaultMessage: "Explore {restaurantName} at {hotelName}",
},
{
restaurantName: restaurantSubPage.name,
hotelName: data.hotelData.name,
}
)
if (restaurantTitleLong.length > 60) {
return restaurantTitleShort
}
return restaurantTitleLong
}
switch (data.subpageUrl) {
case "reviews":
const reviewsTitleLong = intl.formatMessage(
{
defaultMessage:
"Ratings and reviews for {hotelName} in {destination}",
},
{
hotelName: data.hotelData.name,
destination: data.hotelData.address.city,
}
)
const reviewsTitleShort = intl.formatMessage(
{ defaultMessage: "Ratings and reviews for {hotelName}" },
{ hotelName: data.hotelData.name }
)
if (reviewsTitleLong.length > 60) {
return reviewsTitleShort
}
return reviewsTitleLong
case data.additionalHotelData?.hotelParking.nameInUrl:
return intl.formatMessage(
const parkingTitleLong = intl.formatMessage(
{
defaultMessage:
"Parking information for {hotelName} in {destination}",
@@ -40,8 +73,17 @@ export async function getTitle(data: RawMetadataSchema) {
destination: data.hotelData.address.city,
}
)
const parkingTitleShort = intl.formatMessage(
{ defaultMessage: "Parking information for {hotelName}" },
{ hotelName: data.hotelData.name }
)
if (parkingTitleLong.length > 60) {
return parkingTitleShort
}
return parkingTitleLong
case data.additionalHotelData?.healthAndFitness.nameInUrl:
return intl.formatMessage(
const wellnessTitleLong = intl.formatMessage(
{
defaultMessage:
"Gym & Health Facilities at {hotelName} in {destination}",
@@ -51,8 +93,21 @@ export async function getTitle(data: RawMetadataSchema) {
destination: data.hotelData.address.city,
}
)
const wellnessTitleShort = intl.formatMessage(
{
defaultMessage: "Gym & Health Facilities at {hotelName}",
},
{
hotelName: data.hotelData.name,
}
)
if (wellnessTitleLong.length > 60) {
return wellnessTitleShort
}
return wellnessTitleLong
case data.additionalHotelData?.hotelSpecialNeeds.nameInUrl:
return intl.formatMessage(
const accessibilityTitleLong = intl.formatMessage(
{
defaultMessage:
"Accessibility information for {hotelName} in {destination}",
@@ -62,17 +117,43 @@ export async function getTitle(data: RawMetadataSchema) {
destination: data.hotelData.address.city,
}
)
const accessibilityTitleShort = intl.formatMessage(
{
defaultMessage: "Accessibility information for {hotelName}",
},
{
hotelName: data.hotelData.name,
}
)
if (accessibilityTitleLong.length > 60) {
return accessibilityTitleShort
}
return accessibilityTitleLong
case data.additionalHotelData?.meetingRooms.nameInUrl:
return intl.formatMessage(
const meetingsTitleLong = intl.formatMessage(
{
defaultMessage:
"Meetings, Conferences & Events at {hotelName} in {destination}",
"Meetings & Conferences at {hotelName} in {destination}",
},
{
hotelName: data.hotelData.name,
destination: data.hotelData.address.city,
}
)
const meetingsTitleShort = intl.formatMessage(
{
defaultMessage: "Meetings & Conferences at {hotelName}",
},
{
hotelName: data.hotelData.name,
}
)
if (meetingsTitleLong.length > 60) {
return meetingsTitleShort
}
return meetingsTitleLong
default:
break
}