️ Use nextjs layout feature

This commit is contained in:
Luke Vella 2023-02-09 19:50:36 +00:00
parent 02ef9000a7
commit c2c000f770
9 changed files with 168 additions and 154 deletions

View file

@ -16,7 +16,9 @@ import Maintenance from "@/components/maintenance";
import { useCrispChat } from "../components/crisp-chat";
import ModalProvider from "../components/modal/modal-provider";
import { NextPageWithLayout } from "../types";
import { absoluteUrl } from "../utils/absolute-url";
import { UserSession } from "../utils/auth";
import { trpcNext } from "../utils/trpc";
const inter = Inter({
@ -29,7 +31,15 @@ const noto = Noto_Sans_Mono({
display: "swap",
});
const MyApp: NextPage<AppProps> = ({ Component, pageProps }) => {
type PageProps = {
user: UserSession;
};
type AppPropsWithLayout = AppProps<PageProps> & {
Component: NextPageWithLayout<PageProps>;
};
const MyApp: NextPage<AppPropsWithLayout> = ({ Component, pageProps }) => {
useCrispChat();
React.useEffect(() => {
@ -43,6 +53,8 @@ const MyApp: NextPage<AppProps> = ({ Component, pageProps }) => {
return <Maintenance />;
}
const getLayout = Component.getLayout ?? ((page) => page);
return (
<>
<DefaultSeo
@ -77,9 +89,7 @@ const MyApp: NextPage<AppProps> = ({ Component, pageProps }) => {
--font-noto: ${noto.style.fontFamily};
}
`}</style>
<ModalProvider>
<Component {...pageProps} />
</ModalProvider>
<ModalProvider>{getLayout(<Component {...pageProps} />)}</ModalProvider>
</>
);
};