Feat/SW-2152 seo descriptions
* feat(SW-2152): Added improved meta descriptions for hotel pages * feat(SW-2152): Added improved meta descriptions for destination pages * feat(SW-2152): Refactoring metadata description functionality * feat(SW-2152): Improved truncate function and added cities check to country page description Approved-by: Michael Zetterberg Approved-by: Matilda Landström
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { getIntl } from "@/i18n"
|
||||
|
||||
import { truncateTextAfterLastPeriod } from "../truncate"
|
||||
|
||||
import type { RawMetadataSchema } from "@/types/trpc/routers/contentstack/metadata"
|
||||
|
||||
export async function getDestinationCountryPageDescription(
|
||||
data: RawMetadataSchema
|
||||
) {
|
||||
const intl = await getIntl()
|
||||
|
||||
if (!data.destinationData?.location) {
|
||||
return null
|
||||
}
|
||||
|
||||
const { hotelCount, location, cities } = data.destinationData
|
||||
|
||||
let destinationCountryDescription: string | null = null
|
||||
|
||||
if (!hotelCount) {
|
||||
destinationCountryDescription = intl.formatMessage(
|
||||
{
|
||||
defaultMessage:
|
||||
"Discover {location}. Enjoy your stay at a Scandic hotel. Book now!",
|
||||
},
|
||||
{ location }
|
||||
)
|
||||
} else if (!cities || cities.length < 2) {
|
||||
destinationCountryDescription = intl.formatMessage(
|
||||
{
|
||||
defaultMessage:
|
||||
"Discover all our {hotelCount} Scandic hotels in {location}. Enjoy your stay at a Scandic hotel. Book now!",
|
||||
},
|
||||
{ hotelCount, location }
|
||||
)
|
||||
} else {
|
||||
destinationCountryDescription = intl.formatMessage(
|
||||
{
|
||||
defaultMessage:
|
||||
"Discover all our {hotelCount} Scandic hotels in {location}. Explore {city1}, {city2}, and more! All while enjoying your stay at a Scandic hotel. Book now!",
|
||||
},
|
||||
{
|
||||
hotelCount: hotelCount,
|
||||
location: location,
|
||||
city1: cities[0],
|
||||
city2: cities[1],
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return truncateTextAfterLastPeriod(destinationCountryDescription)
|
||||
}
|
||||
Reference in New Issue
Block a user