owncast/web/pages/_app.tsx
Gabe Kangas c05a20a460
Use built-in Next layout support + lazy load
Instead of doing manual layout switching use the Nextjs nested layout
support. Also add some additional lazy loading of components. This is to
work on performance score re: #2167.
2023-01-09 01:08:24 -08:00

35 lines
1 KiB
TypeScript

// All these imports are almost exclusively for the Admin.
// We should not be loading them for the main frontend UI.
// order matters!
import '../styles/variables.css';
import '../styles/global.less';
import '../styles/globals.scss';
import '../styles/ant-overrides.scss';
// TODO: Move this videojs sass to the player component.
import '../components/video/VideoJS/VideoJS.scss';
import { AppProps } from 'next/app';
import { ReactElement, ReactNode } from 'react';
import { NextPage } from 'next';
import { RecoilRoot } from 'recoil';
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
getLayout?: (page: ReactElement) => ReactNode;
};
type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout;
};
export default function App({ Component, pageProps }: AppPropsWithLayout) {
// Use the layout defined at the page level, if available
const getLayout = Component.getLayout ?? (page => page);
return getLayout(
<RecoilRoot>
<Component {...pageProps} />
</RecoilRoot>,
);
}