feat(SW-201): Added structured data for hotel pages
This commit is contained in:
@@ -69,7 +69,10 @@ export async function getTitle(data: RawMetadataSchema) {
|
||||
if (data.hotelData) {
|
||||
return intl.formatMessage(
|
||||
{ id: "Stay at HOTEL_NAME | Hotel in DESTINATION" },
|
||||
{ hotelName: data.hotelData.name, destination: data.hotelData.city }
|
||||
{
|
||||
hotelName: data.hotelData.name,
|
||||
destination: data.hotelData.address.city,
|
||||
}
|
||||
)
|
||||
}
|
||||
if (data.web?.breadcrumbs?.title) {
|
||||
@@ -84,14 +87,13 @@ export async function getTitle(data: RawMetadataSchema) {
|
||||
return ""
|
||||
}
|
||||
|
||||
export async function getDescription(data: RawMetadataSchema) {
|
||||
const intl = await getIntl()
|
||||
export function getDescription(data: RawMetadataSchema) {
|
||||
const metadata = data.web?.seo_metadata
|
||||
if (metadata?.description) {
|
||||
return metadata.description
|
||||
}
|
||||
if (data.hotelData) {
|
||||
return data.hotelData.description
|
||||
return data.hotelData.hotelContent.texts.descriptions.short
|
||||
}
|
||||
if (data.preamble) {
|
||||
return truncateTextAfterLastPeriod(data.preamble)
|
||||
@@ -118,6 +120,9 @@ export async function getDescription(data: RawMetadataSchema) {
|
||||
export function getImage(data: RawMetadataSchema) {
|
||||
const metadataImage = data.web?.seo_metadata?.seo_image
|
||||
const heroImage = data.hero_image
|
||||
const hotelImage =
|
||||
data.hotelData?.gallery?.heroImages?.[0] ||
|
||||
data.hotelData?.gallery?.smallerImages?.[0]
|
||||
|
||||
// Currently we don't have the possibility to get smaller images from ImageVault (2024-11-15)
|
||||
if (metadataImage) {
|
||||
@@ -128,8 +133,11 @@ export function getImage(data: RawMetadataSchema) {
|
||||
height: metadataImage.dimensions.height,
|
||||
}
|
||||
}
|
||||
if (data.hotelData?.image) {
|
||||
return data.hotelData.image
|
||||
if (hotelImage) {
|
||||
return {
|
||||
url: hotelImage.imageSizes.small,
|
||||
alt: hotelImage.metaData.altText || undefined,
|
||||
}
|
||||
}
|
||||
if (heroImage) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user