update game url to use game code directly

This commit is contained in:
Nathaniel Tampus
2023-03-15 19:54:15 +08:00
parent b368d7bdf5
commit 3821c4b43a
7 changed files with 8 additions and 13 deletions

View File

@@ -0,0 +1,44 @@
import GameAuthWrapper from "@/components/game/GameAuthWrapper";
import { getGame } from "@/lib/game";
import { notFound } from "next/navigation";
export async function generateMetadata({ params }: { params: { code: string } }) {
const game = await getGame(params.code);
if (!game) {
return {
description: "Game not found",
robots: {
index: false,
follow: false,
nocache: true,
noarchive: true
}
};
}
return {
description: `Play or watch a game with ${game.host?.name}`,
openGraph: {
title: "chessu",
description: `Play or watch a game with ${game.host?.name}`,
url: `https://ches.su/${game.code}`,
siteName: "chessu",
locale: "en_US",
type: "website"
},
robots: {
index: false,
follow: false,
nocache: true,
noarchive: true
}
};
}
export default async function Game({ params }: { params: { code: string } }) {
const game = await getGame(params.code);
if (!game) {
notFound();
}
return <GameAuthWrapper initialLobby={game} />;
}