Commit b1ae789a by Arjun Jhukal

minor change

parent f1e4dee6
import ExclusiveGameDetail from "@/components/pages/dashboard/userDashboard/games/exclusiveGames/exclusiveGameDetail"; import ExclusiveGameDetail from "@/components/pages/dashboard/userDashboard/games/exclusiveGames/exclusiveGameDetail";
import { getSingleGame } from "@/serverApi/game"; import { getSingleGame } from "@/serverApi/game";
import { Metadata } from "next"; import { Metadata } from "next";
import { notFound } from "next/navigation";
const SITE_URL = process.env.NEXT_PUBLIC_FRONTEND_URL!; const SITE_URL = process.env.NEXT_PUBLIC_FRONTEND_URL!;
export async function generateMetadata(props: { params: Promise<{ id: string }> }): Promise<Metadata> { type PageProps = {
const { id } = await props.params; params: { id: string };
const canonicalUrl = `${SITE_URL}/exclusive-games/${id}`.replace(/\/$/, ""); };
const game = await getSingleGame(id);
export async function generateMetadata(
{ params }: PageProps
): Promise<Metadata> {
try {
const { id } = params;
const canonicalUrl = `${SITE_URL}/exclusive-games/${id}`.replace(/\/$/, "");
const game = await getSingleGame(id);
return { if (!game?.data) {
title: game?.data?.meta?.meta_title || game?.data?.name, return {};
description: game?.data?.meta?.meta_description || game?.data?.name, }
openGraph: {
title: game?.data?.meta?.meta_title || game?.data?.name, return {
description: game?.data?.meta?.meta_description || game?.data?.name, title: game.data.meta?.meta_title || game.data.name,
images: game?.data?.meta?.og_image_url description: game.data.meta?.meta_description || game.data.name,
}, openGraph: {
twitter: { title: game.data.meta?.meta_title || game.data.name,
title: game?.data?.meta?.meta_title || game?.data?.name, description: game.data.meta?.meta_description || game.data.name,
description: game?.data?.meta?.meta_description || game?.data?.name, images: game.data.meta?.og_image_url,
images: game?.data?.meta?.og_image_url },
}, twitter: {
alternates: { title: game.data.meta?.meta_title || game.data.name,
canonical: canonicalUrl, description: game.data.meta?.meta_description || game.data.name,
}, images: game.data.meta?.og_image_url,
}; },
alternates: {
canonical: canonicalUrl,
},
};
} catch {
return {};
}
} }
export default async function UserGameDetail(props: { params: Promise<{ id: string }> }) { export default async function UserGameDetail(props: { params: Promise<{ id: string }> }) {
...@@ -33,5 +48,9 @@ export default async function UserGameDetail(props: { params: Promise<{ id: stri ...@@ -33,5 +48,9 @@ export default async function UserGameDetail(props: { params: Promise<{ id: stri
const game = await getSingleGame(id); const game = await getSingleGame(id);
if (!game?.data) {
notFound();
}
return <ExclusiveGameDetail game={game} />; return <ExclusiveGameDetail game={game} />;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment