next.ts17 lines · main
| 1 | import type { NextPage } from 'next' |
| 2 | import type { AppProps } from 'next/app' |
| 3 | import type { ComponentType, ReactElement, ReactNode } from 'react' |
| 4 | |
| 5 | export type AppPropsWithLayout = AppProps<{ dehydratedState: any }> & { |
| 6 | Component: NextPageWithLayout |
| 7 | } |
| 8 | |
| 9 | export type NextPageWithLayout<P = { dehydratedState: any }, IP = P> = NextPage<P, IP> & { |
| 10 | getLayout?: (page: ReactElement) => ReactNode |
| 11 | } |
| 12 | |
| 13 | export function isNextPageWithLayout<T>( |
| 14 | Component: ComponentType<T> | NextPageWithLayout<T, T> |
| 15 | ): Component is NextPageWithLayout<T, T> { |
| 16 | return 'getLayout' in Component && typeof Component.getLayout === 'function' |
| 17 | } |