1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-10-28 20:55:47 -04:00

remove per-page getLayout option (maybe temporarily?)

This commit is contained in:
2022-04-19 17:38:20 -04:00
parent d5690d2972
commit d50ae0f85a
10 changed files with 228 additions and 314 deletions

View File

@@ -9,18 +9,10 @@ import * as config from "../lib/config";
import { defaultSeo, socialProfileJsonLd } from "../lib/config/seo";
import { themeClassNames } from "../lib/styles/helpers/themes";
import { globalStyles } from "../lib/styles/stitches.config";
import type { ReactElement, ReactNode } from "react";
import type { NextPage } from "next";
import type { AppProps as NextAppProps } from "next/app";
// https://nextjs.org/docs/basic-features/layouts#with-typescript
export type AppProps = NextAppProps & {
Component: NextPage & {
getLayout?: (page: ReactElement) => ReactNode;
};
};
const App = ({ Component, pageProps }: AppProps) => {
const App = ({ Component, pageProps }: NextAppProps) => {
const router = useRouter();
// get this page's URL with full domain, and hack around query parameters and anchors
@@ -48,14 +40,11 @@ const App = ({ Component, pageProps }: AppProps) => {
// unassign event listener
router.events.off("routeChangeComplete", onRouteChangeComplete);
};
}, []); // eslint-disable-line react-hooks/exhaustive-deps
}, [router.events]);
// inject body styles defined in ../lib/styles/stitches.config.ts
globalStyles();
// allow layout overrides per-page, but default to plain `<Layout />`
const getLayout = Component.getLayout || ((page) => <Layout>{page}</Layout>);
return (
<ThemeProvider classNames={themeClassNames}>
{/* all SEO config is in ../lib/config/seo.ts except for canonical URLs, which require access to next router */}
@@ -72,7 +61,9 @@ const App = ({ Component, pageProps }: AppProps) => {
/>
<SocialProfileJsonLd {...socialProfileJsonLd} />
{getLayout(<Component {...pageProps} />)}
<Layout>
<Component {...pageProps} />
</Layout>
</ThemeProvider>
);
};