Merged in SW-3490-set-metadata-for-routes (pull request #2881)
SW-3490 set metadata for routes * feat(SW-3490): Set metadata title for hotelreservation paths Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -1,11 +1,52 @@
|
||||
import { AlternativeHotelsMapPage as AlternativeHotelsMapPagePrimitive } from "@scandic-hotels/booking-flow/pages/AlternativeHotelsMapPage"
|
||||
|
||||
import { getHotel } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
params,
|
||||
}: PageArgs<LangParams, { hotel: string }>): Promise<Metadata> {
|
||||
const intl = await getIntl()
|
||||
|
||||
const { hotel } = await searchParams
|
||||
const { lang } = await params
|
||||
|
||||
if (!hotel || Array.isArray(hotel)) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const hotelData = await getHotel({
|
||||
hotelId: hotel,
|
||||
language: lang,
|
||||
isCardOnlyPayment: false,
|
||||
})
|
||||
const hotelName = hotelData?.additionalData?.name
|
||||
|
||||
if (!hotelName) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const title = intl.formatMessage(
|
||||
{
|
||||
defaultMessage: "Alternatives for {value}",
|
||||
},
|
||||
{
|
||||
value: hotelName,
|
||||
}
|
||||
)
|
||||
|
||||
return { title }
|
||||
}
|
||||
|
||||
export default async function AlternativeHotelsMapPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
) {
|
||||
|
||||
@@ -1,13 +1,54 @@
|
||||
import { AlternativeHotelsPage as AlternativeHotelsPagePrimitive } from "@scandic-hotels/booking-flow/pages/AlternativeHotelsPage"
|
||||
|
||||
import { getHotel } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import {
|
||||
type LangParams,
|
||||
type NextSearchParams,
|
||||
type PageArgs,
|
||||
} from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
params,
|
||||
}: PageArgs<LangParams, { hotel: string }>): Promise<Metadata> {
|
||||
const intl = await getIntl()
|
||||
|
||||
const { hotel } = await searchParams
|
||||
const { lang } = await params
|
||||
|
||||
if (!hotel || Array.isArray(hotel)) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const hotelData = await getHotel({
|
||||
hotelId: hotel,
|
||||
language: lang,
|
||||
isCardOnlyPayment: false,
|
||||
})
|
||||
const hotelName = hotelData?.additionalData?.name
|
||||
|
||||
if (!hotelName) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const title = intl.formatMessage(
|
||||
{
|
||||
defaultMessage: "Alternatives for {value}",
|
||||
},
|
||||
{
|
||||
value: hotelName,
|
||||
}
|
||||
)
|
||||
|
||||
return { title }
|
||||
}
|
||||
|
||||
export default async function AlternativeHotelsPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
) {
|
||||
|
||||
@@ -2,6 +2,8 @@ import { EnterDetailsPage as EnterDetailsPagePrimitive } from "@scandic-hotels/b
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export { generateMetadata } from "@/utils/metadata/generateMetadata"
|
||||
|
||||
export default async function DetailsPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
) {
|
||||
|
||||
@@ -8,6 +8,8 @@ import styles from "./page.module.css"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export { generateMetadata } from "@/utils/metadata/generateMetadata"
|
||||
|
||||
export default async function HotelReservationPage(
|
||||
props: PageArgs<LangParams>
|
||||
) {
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import { SelectHotelMapPage as SelectHotelMapPagePrimitive } from "@scandic-hotels/booking-flow/pages/SelectHotelMapPage"
|
||||
import { toCapitalCase } from "@scandic-hotels/common/utils/toCapitalCase"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, { city: string }>): Promise<Metadata> {
|
||||
const { city } = await searchParams
|
||||
|
||||
return {
|
||||
title: `${toCapitalCase(city)}`,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SelectHotelMapPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
) {
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
import { SelectHotelPage as SelectHotelPagePrimitive } from "@scandic-hotels/booking-flow/pages/SelectHotelPage"
|
||||
import { toCapitalCase } from "@scandic-hotels/common/utils/toCapitalCase"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, { city: string }>): Promise<Metadata> {
|
||||
const { city } = await searchParams
|
||||
|
||||
return {
|
||||
title: `${toCapitalCase(city)}`,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SelectHotelPage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
) {
|
||||
|
||||
@@ -1,13 +1,39 @@
|
||||
import { SelectRatePage as SelectRatePagePrimitive } from "@scandic-hotels/booking-flow/pages/SelectRatePage"
|
||||
|
||||
import { getHotel } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { Metadata } from "next"
|
||||
|
||||
import {
|
||||
type LangParams,
|
||||
type NextSearchParams,
|
||||
type PageArgs,
|
||||
} from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
searchParams,
|
||||
params,
|
||||
}: PageArgs<LangParams, { hotel: string }>): Promise<Metadata> {
|
||||
const { hotel } = await searchParams
|
||||
const { lang } = await params
|
||||
|
||||
const hotelData = await getHotel({
|
||||
hotelId: hotel,
|
||||
language: lang,
|
||||
isCardOnlyPayment: false,
|
||||
})
|
||||
|
||||
if (!hotelData?.additionalData?.name) {
|
||||
return {}
|
||||
}
|
||||
|
||||
return {
|
||||
title: hotelData.additionalData.name,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SelectRatePage(
|
||||
props: PageArgs<LangParams, NextSearchParams>
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user