Commit 3be9b37b by Arjun Jhukal

minor change

parent 777f0bbc
import ExclusiveGameDetail from "@/components/pages/dashboard/userDashboard/games/exclusiveGames/exclusiveGameDetail";
import { getAllGames, getSingleGame } from "@/serverApi/game";
import { Metadata } from "next";
import { notFound } from "next/navigation";
const SITE_URL = process.env.NEXT_PUBLIC_FRONTEND_URL!;
export async function generateMetadata(props: { params: Promise<{ id: string }> }): Promise<Metadata> {
const { id } = await props.params;
const canonicalUrl = `${SITE_URL}/exclusive-games/${id}`.replace(/\/$/, "");
const game = await getSingleGame(id);
type PageProps = {
params: { id: string };
};
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);
if (!game?.data) {
return {};
}
return {
title: game?.data?.meta?.meta_title || game?.data?.name,
description: game?.data?.meta?.meta_description || game?.data?.name,
openGraph: {
title: game?.data?.meta?.meta_title || game?.data?.name,
description: game?.data?.meta?.meta_description || game?.data?.name,
images: game?.data?.meta?.og_image_url
},
twitter: {
title: game?.data?.meta?.meta_title || game?.data?.name,
description: game?.data?.meta?.meta_description || game?.data?.name,
images: game?.data?.meta?.og_image_url
},
alternates: {
canonical: canonicalUrl,
},
};
return {
title: game.data.meta?.meta_title || game.data.name,
description: game.data.meta?.meta_description || game.data.name,
openGraph: {
title: game.data.meta?.meta_title || game.data.name,
description: game.data.meta?.meta_description || game.data.name,
images: game.data.meta?.og_image_url,
},
twitter: {
title: game.data.meta?.meta_title || game.data.name,
description: game.data.meta?.meta_description || game.data.name,
images: game.data.meta?.og_image_url,
},
alternates: {
canonical: canonicalUrl,
},
};
} catch {
return {};
}
}
export async function generateStaticParams() {
const res = await getAllGames()
const res = await getAllGames();
const games = res?.data?.data ?? [];
const games = res?.data?.data ?? []
return games.map((game: any) => ({
id: String(game.id),
}))
return games
.filter((game: any) => game?.id)
.map((game: any) => ({
id: String(game.id),
}));
}
export const dynamic = 'force-static';
export const dynamic = "force-static";
export default async function UserGameDetail(props: { params: Promise<{ id: string }> }) {
const { id } = await props.params;
export default async function UserGameDetail({ params }: PageProps) {
const { id } = params;
const game = await getSingleGame(id);
if (!game?.data) {
notFound();
}
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