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
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import { getIntl } from "@/i18n"
|
|
|
|
import type { RawMetadataSchema } from "@scandic-hotels/trpc/routers/contentstack/metadata/output"
|
|
|
|
export async function getDestinationPageTitle(
|
|
data: RawMetadataSchema,
|
|
pageType: "city" | "country"
|
|
) {
|
|
const intl = await getIntl()
|
|
const { destinationData } = data
|
|
if (!destinationData) {
|
|
return null
|
|
}
|
|
|
|
const location = destinationData.location
|
|
|
|
if (!location) {
|
|
return null
|
|
}
|
|
const destinationTitle =
|
|
pageType === "country"
|
|
? intl.formatMessage(
|
|
{
|
|
id: "destination.destinationsInLocation",
|
|
defaultMessage: "Destinations in {location}",
|
|
},
|
|
{ location }
|
|
)
|
|
: intl.formatMessage(
|
|
{
|
|
id: "destination.hotelsInLocation",
|
|
defaultMessage: "Hotels in {location}",
|
|
},
|
|
{ location }
|
|
)
|
|
|
|
return destinationTitle
|
|
}
|
|
|
|
export function getDestinationFilterSeoMetaTitle(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?.title) {
|
|
return foundSeoFilter.seo_metadata.title
|
|
}
|
|
|
|
return foundSeoFilter.heading
|
|
}
|
|
|
|
return null
|
|
}
|