import { Outlet, RouterProvider, ScrollRestoration, createBrowserRouter, redirect } from "react-router-dom"
import { HomePage } from "./HomePage";
import { GamePage } from "./GamePage";

const RouteRoot = () => {
	return <>
		{/* <Nav> */}
			<ScrollRestoration />
			<Outlet/>
		{/* </Nav> */}
	</>
}

const router = createBrowserRouter([
	{
		element: <RouteRoot/>,
		children: [
			{
				path: "/",
				element: <HomePage/>,
				// loader: () => {
				// 	return redirect("/megachat");
				// }
			},
			{
				path: "/u/:author/:slug",
				element: <GamePage/>,
			},
			{
				path: "/u/:author/:slug/:version",
				element: <GamePage/>,
			},
		],
	},
]);

export const Routing = () => <RouterProvider router={router} />;