import { useRouter } from 'next/router' import dynamic from 'next/dynamic' import useLazyLoadHighlightJS from 'components/hooks/useLazyLoadHighlightJS' import { DefaultLayout } from 'components/DefaultLayout' import { ArticleTitle } from 'components/article/ArticleTitle' import { MarkdownContent } from 'components/ui/MarkdownContent' import { Lead } from 'components/ui/Lead' import { ArticleGridLayout } from './ArticleGridLayout' import { MiniTocs } from 'components/ui/MiniTocs' import { useAutomatedPageContext } from 'components/context/AutomatedPageContext' const ClientSideHighlightJS = dynamic(() => import('./ClientSideHighlightJS'), { ssr: false }) type Props = { children: React.ReactNode } export const AutomatedPage = ({ children }: Props) => { const { asPath } = useRouter() const { title, intro, renderedPage, miniTocItems } = useAutomatedPageContext() const lazyLoadHighlightJS = useLazyLoadHighlightJS(asPath) return ( {/* Doesn't matter *where* this is included because it will never render anything. It always just return null. */} {lazyLoadHighlightJS && }
{title}} intro={ intro && ( {intro} ) } toc={ miniTocItems.length > 1 && } >
{renderedPage && ( {renderedPage} )} {children && {children}}
) }