-
Yusuf Akgül authoredYusuf Akgül authored
page.tsx 808 B
import { getGame, getGames } from "@/lib/igdb";
import { IGame } from "@/types/types";
import Image from "next/image";
// renders a single game detail page
export default async function GameDetail({ params }: { params: { gameid: string } }) {
const data: IGame[] = await getGame(parseInt(params.gameid))
return (
<div>
<h1>Game Detail</h1>
<h1>{data[0].name}</h1>
<Image src={data[0].cover.url} alt={data[0].name} width={264} height={374} priority={true} />
<p>{data[0].summary}</p>
</div>
)
}
// pre-renders static paths for all fetched games for faster page loads
export async function generateStaticParams() {
const games = await getGames()
return games.map((game) => ({
gameid: game.id.toString(),
}));
}