update game url to use game code directly
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
export default function NotFound() {
|
export default function NotFound() {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center gap-4">
|
<div className="flex flex-col items-center justify-center gap-4">
|
||||||
<div className="text-2xl font-bold">Error</div>
|
<div className="text-2xl font-bold">Error 404</div>
|
||||||
<div className="text-xl">Game not found</div>
|
<div className="text-xl">Not found</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ export async function generateMetadata({ params }: { params: { code: string } })
|
|||||||
openGraph: {
|
openGraph: {
|
||||||
title: "chessu",
|
title: "chessu",
|
||||||
description: `Play or watch a game with ${game.host?.name}`,
|
description: `Play or watch a game with ${game.host?.name}`,
|
||||||
url: `https://ches.su/game/${game.code}`,
|
url: `https://ches.su/${game.code}`,
|
||||||
siteName: "chessu",
|
siteName: "chessu",
|
||||||
locale: "en_US",
|
locale: "en_US",
|
||||||
type: "website"
|
type: "website"
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { redirect } from "next/navigation";
|
|
||||||
|
|
||||||
export default function GameEmpty() {
|
|
||||||
redirect("/");
|
|
||||||
}
|
|
||||||
@@ -362,7 +362,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function copyInvite() {
|
function copyInvite() {
|
||||||
const text = `https://ches.su/game/${initialLobby.code}`;
|
const text = `https://ches.su/${initialLobby.code}`;
|
||||||
if ("clipboard" in navigator) {
|
if ("clipboard" in navigator) {
|
||||||
navigator.clipboard.writeText(text);
|
navigator.clipboard.writeText(text);
|
||||||
} else {
|
} else {
|
||||||
@@ -526,7 +526,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
|
|||||||
onClick={copyInvite}
|
onClick={copyInvite}
|
||||||
>
|
>
|
||||||
<IconCopy size={16} />
|
<IconCopy size={16} />
|
||||||
ches.su/game/{initialLobby.code}
|
ches.su/{initialLobby.code}
|
||||||
</label>
|
</label>
|
||||||
<div tabIndex={0} className="dropdown-content badge badge-md badge-primary shadow">
|
<div tabIndex={0} className="dropdown-content badge badge-md badge-primary shadow">
|
||||||
copied to clipboard
|
copied to clipboard
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default function CreateGame() {
|
|||||||
const game = await createGame(startingSide, unlisted.checked);
|
const game = await createGame(startingSide, unlisted.checked);
|
||||||
|
|
||||||
if (game) {
|
if (game) {
|
||||||
router.push(`/game/${game.code}`);
|
router.push(`/${game.code}`);
|
||||||
} else {
|
} else {
|
||||||
setButtonLoading(false);
|
setButtonLoading(false);
|
||||||
// TODO: Show error message
|
// TODO: Show error message
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default function JoinGame() {
|
|||||||
const game = await getGame(code);
|
const game = await getGame(code);
|
||||||
|
|
||||||
if (game && game.code) {
|
if (game && game.code) {
|
||||||
router.push(`/game/${game.code}`);
|
router.push(`/${game.code}`);
|
||||||
} else {
|
} else {
|
||||||
setButtonLoading(false);
|
setButtonLoading(false);
|
||||||
setNotFound(true);
|
setNotFound(true);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default function JoinButton({ code }: { code: string }) {
|
|||||||
|
|
||||||
function handleJoin() {
|
function handleJoin() {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
router.push(`/game/${code}`);
|
router.push(`/${code}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user