feat(SW-266): Moved logic for breadcrumbs since I cant pass custom prop to generateMetadata
This commit is contained in:
@@ -5,23 +5,11 @@ import Title from "@/components/TempDesignSystem/Text/Title"
|
||||
import TrackingSDK from "@/components/TrackingSDK"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
import { generateMetadata as generateBaseMetadata } from "@/utils/generateMetadata"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export async function generateMetadata({ params }: PageArgs<LangParams>) {
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get()
|
||||
if (!breadcrumbs?.length) {
|
||||
return null
|
||||
}
|
||||
return generateBaseMetadata({
|
||||
params,
|
||||
pageTitle: breadcrumbs.at(-1)?.title,
|
||||
})
|
||||
}
|
||||
|
||||
export default async function MyPages({
|
||||
params,
|
||||
}: PageArgs<LangParams & { path: string[] }>) {
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import ContentPage from "@/components/ContentType/ContentPage"
|
||||
import HotelPage from "@/components/ContentType/HotelPage/HotelPage"
|
||||
import LoyaltyPage from "@/components/ContentType/LoyaltyPage/LoyaltyPage"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
import { generateMetadata as generateBaseMetadata } from "@/utils/generateMetadata"
|
||||
|
||||
import {
|
||||
ContentTypeParams,
|
||||
@@ -15,24 +12,6 @@ import {
|
||||
UIDParams,
|
||||
} from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: PageArgs<LangParams & ContentTypeParams>) {
|
||||
switch (params.contentType) {
|
||||
case "loyalty-page":
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get()
|
||||
if (!breadcrumbs?.length) {
|
||||
return null
|
||||
}
|
||||
return generateBaseMetadata({
|
||||
params,
|
||||
pageTitle: breadcrumbs.at(-1)?.title,
|
||||
})
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
export default async function ContentTypePage({
|
||||
params,
|
||||
}: PageArgs<LangParams & ContentTypeParams & UIDParams, {}>) {
|
||||
|
||||
Reference in New Issue
Block a user