feat(SW-266): Replacing static metadata with data from Contentstack on Loyalty pages and Account Pages
This commit is contained in:
@@ -5,11 +5,20 @@ 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 accountPageRes = await serverClient().contentstack.accountPage.get()
|
||||
return generateBaseMetadata({
|
||||
params,
|
||||
pageTitle: accountPageRes?.accountPage?.title,
|
||||
})
|
||||
}
|
||||
|
||||
export default async function MyPages({
|
||||
params,
|
||||
}: PageArgs<LangParams & { path: string[] }>) {
|
||||
@@ -34,7 +43,6 @@ export default async function MyPages({
|
||||
<p>{formatMessage({ id: "No content published" })}</p>
|
||||
)}
|
||||
</main>
|
||||
|
||||
<TrackingSDK pageData={tracking} />
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
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,
|
||||
@@ -12,6 +15,22 @@ import {
|
||||
UIDParams,
|
||||
} from "@/types/params"
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: PageArgs<LangParams & ContentTypeParams>) {
|
||||
switch (params.contentType) {
|
||||
case "loyalty-page":
|
||||
const loyaltyPageRes = await serverClient().contentstack.loyaltyPage.get()
|
||||
return generateBaseMetadata({
|
||||
params,
|
||||
pageTitle: loyaltyPageRes?.loyaltyPage?.title,
|
||||
})
|
||||
// Add case "hotel-pages" etc when needed
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
export default async function ContentTypePage({
|
||||
params,
|
||||
}: PageArgs<LangParams & ContentTypeParams & UIDParams, {}>) {
|
||||
|
||||
@@ -12,15 +12,11 @@ import { preloadUserTracking } from "@/components/TrackingSDK"
|
||||
import { getIntl } from "@/i18n"
|
||||
import ServerIntlProvider from "@/i18n/Provider"
|
||||
import { getLang, setLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { Metadata } from "next"
|
||||
import { generateMetadata } from "@/utils/generateMetadata"
|
||||
|
||||
import type { LangParams, LayoutArgs } from "@/types/params"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
description: "New web",
|
||||
title: "Scandic Hotels",
|
||||
}
|
||||
export { generateMetadata }
|
||||
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
@@ -33,8 +29,8 @@ export default async function RootLayout({
|
||||
>) {
|
||||
setLang(params.lang)
|
||||
preloadUserTracking()
|
||||
|
||||
const { defaultLocale, locale, messages } = await getIntl()
|
||||
|
||||
return (
|
||||
<html lang={getLang()}>
|
||||
<head>
|
||||
|
||||
Reference in New Issue
Block a user