import { LocationProvider, Router, Route, hydrate, prerender as ssr } from 'preact-iso';
import './style.css';
import Home from './pages/Home/index.jsx';
import NotFound from './pages/_404.jsx';

export function App() {
    const routes = [
        { desc: "Home", path: "/", component: Home }, 
    ]

    const links = routes.map(route => ({desc: route.desc, path: route.path}))

	return (
		<LocationProvider>
			<main>
				<Router>
                    {routes.map(route => (
                        <Route path={route.path} component={route.component} />
                    ))}
                    <Route default component={NotFound} />
				</Router>
			</main>
		</LocationProvider>
	);
}

if (typeof window !== 'undefined') {
	hydrate(<App />, document.getElementById('app'));
}

export async function prerender(data) {
	return await ssr(<App {...data} />);
}
