Newer
Older

Yusuf Akgül
committed
import { getGame, getGames } from "@/lib/igdb";
import { IGame } from "@/types/types";

Yusuf Akgül
committed
// renders a single game detail page
export default async function GameDetail({ params }: { params: { gameid: string } }) {
const data: IGame[] = await getGame(parseInt(params.gameid))

Yusuf Akgül
committed
<h1>Game Detail</h1>

Yusuf Akgül
committed
<Image src={data[0].cover.url} alt={data[0].name} width={264} height={374} priority={true} />
<p>{data[0].summary}</p>
</div>
)
}

Yusuf Akgül
committed
// 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(),
}));
}