Feat/lokalise rebuild * chore(lokalise): update translation ids * chore(lokalise): easier to switch between projects * chore(lokalise): update translation ids * . * . * . * . * . * . * chore(lokalise): update translation ids * chore(lokalise): update translation ids * . * . * . * chore(lokalise): update translation ids * chore(lokalise): update translation ids * . * . * chore(lokalise): update translation ids * chore(lokalise): update translation ids * chore(lokalise): new translations * merge * switch to errors for missing id's * merge * sync translations Approved-by: Linus Flood
116 lines
3.3 KiB
TypeScript
116 lines
3.3 KiB
TypeScript
import { getIntl } from "@/i18n"
|
|
|
|
import { truncateTextAfterLastPeriod } from "../truncate"
|
|
|
|
import type { RawMetadataSchema } from "@scandic-hotels/trpc/routers/contentstack/metadata/output"
|
|
|
|
export async function getDestinationCityPageDescription(
|
|
data: RawMetadataSchema
|
|
) {
|
|
const intl = await getIntl()
|
|
|
|
if (!data.destinationData?.location) {
|
|
return null
|
|
}
|
|
|
|
const { hotelCount, location } = data.destinationData
|
|
|
|
if (hotelCount === 1) {
|
|
const destinationCitySingleHotelDescription = intl.formatMessage(
|
|
{
|
|
id: "metadata.destinationCitySingleHotel",
|
|
defaultMessage:
|
|
"Discover our Scandic hotel in {location}. Start your day with a delicious breakfast before exploring {location}. Book your stay at a Scandic hotel now!",
|
|
},
|
|
{ location }
|
|
)
|
|
|
|
return truncateTextAfterLastPeriod(destinationCitySingleHotelDescription)
|
|
}
|
|
const destinationCityMultipleHotelDescription = intl.formatMessage(
|
|
{
|
|
id: "metadata.destinationCityMultipleHotels",
|
|
defaultMessage:
|
|
"Discover all our {hotelCount} Scandic hotels in {location}. Start your day with a delicious breakfast before exploring {location}. Book your stay at a Scandic hotel now!",
|
|
},
|
|
{ hotelCount, location }
|
|
)
|
|
|
|
return truncateTextAfterLastPeriod(destinationCityMultipleHotelDescription)
|
|
}
|
|
|
|
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(
|
|
{
|
|
id: "metadata.discoverLocation",
|
|
defaultMessage:
|
|
"Discover {location}. Enjoy your stay at a Scandic hotel. Book now!",
|
|
},
|
|
{ location }
|
|
)
|
|
} else if (!cities || cities.length < 2) {
|
|
destinationCountryDescription = intl.formatMessage(
|
|
{
|
|
id: "metadata.discoverHotelsInLocation",
|
|
defaultMessage:
|
|
"Discover all our {hotelCount} Scandic hotels in {location}. Enjoy your stay at a Scandic hotel. Book now!",
|
|
},
|
|
{ hotelCount, location }
|
|
)
|
|
} else {
|
|
destinationCountryDescription = intl.formatMessage(
|
|
{
|
|
id: "metadata.discoverHotelsInTwoCities",
|
|
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)
|
|
}
|
|
|
|
export function getDestinationFilterSeoMetaDescription(
|
|
data: RawMetadataSchema
|
|
) {
|
|
const filter = data.destinationData?.filter
|
|
|
|
if (!filter) {
|
|
return null
|
|
}
|
|
const foundSeoFilter = data.seo_filters?.find(
|
|
(f) => f.filterConnection.edges[0]?.node?.slug === filter
|
|
)
|
|
|
|
if (foundSeoFilter) {
|
|
if (foundSeoFilter.seo_metadata?.description) {
|
|
return foundSeoFilter.seo_metadata.description
|
|
}
|
|
|
|
if (foundSeoFilter.preamble) {
|
|
return truncateTextAfterLastPeriod(foundSeoFilter.preamble)
|
|
}
|
|
}
|
|
|
|
return null
|
|
}
|