Make each admin page specify is own layout. Closes #2584

This commit is contained in:
Gabe Kangas
2023-01-15 23:11:44 -08:00
parent 3b232f31e1
commit 2853752937
24 changed files with 167 additions and 37 deletions

View File

@@ -14,9 +14,6 @@ import { AppProps } from 'next/app';
import { ReactElement, ReactNode } from 'react';
import { NextPage } from 'next';
import { RecoilRoot } from 'recoil';
import { Router, useRouter } from 'next/router';
import { AdminLayout } from '../components/layouts/AdminLayout';
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
getLayout?: (page: ReactElement) => ReactNode;
@@ -27,12 +24,6 @@ type AppPropsWithLayout = AppProps & {
};
export default function App({ Component, pageProps }: AppPropsWithLayout) {
const router = useRouter() as Router;
const isAdminPage = router.pathname.startsWith('/admin');
if (isAdminPage) {
return <AdminLayout pageProps={pageProps} Component={Component} router={router} />;
}
const layout = Component.getLayout ?? (page => page);
return layout(