{ const isExtern = href.indexOf('http') !== -1 const isAnchor = href.indexOf('#') === 0 const resolvedHref = isExtern ? href : isAnchor ? router.pathname + href : docsPath + href return ( {children} ) }, pre: ({ children }) => children, h1: ({ children }) => {children}, h2: ({ children }) => {children}, h3: ({ children }) => {children}, h4: ({ children }) => {children}, h5: ({ children }) => {children}, strong: ({ children }) => ( {children} ), ul: ({ children }) => ( {children} ), ol: ({ children }) => ( {children} ), blockquote: ({ children }) => ( {children} ), code: CodeBlock, inlineCode: ({ children }) => ( {children} ), p: ({ children }) => ( {children} ), img: ({ src, title, alt }) => ( ), tr: ({ children }) => ( {children} ), td: ({ children }) => ( {children} ), th: ({ children }) => ( {children} ), table: ({ children }) => ( {children} ), hr: () => , }} /> ) } function NavigationItem({ path, group, page, docsPath }) { const router = useRouter() const isExtern = path.indexOf('http') === 0 const isCurrentPage = router.asPath === docsPath + path return ( {page} ) } export default function DocLayout({ children, toc, version, headings }) { const [navigationVisible, setNavigationVisible] = useState(false) const { theme } = useFela() const router = useRouter() const flatNav = getFlatNav(toc) const docsPath = `/docs/${version}/` const currentPage = flatNav[router.asPath.substr(docsPath.length).split('#')[0]] useEffect(() => { if (navigationVisible) { const handleResize = () => { if (window.innerWidth >= 800) { setNavigationVisible(false) } } window.addEventListener('resize', handleResize) return () => window.removeEventListener('resize', handleResize) } }, [navigationVisible]) useEffect(() => { const handleRouteChange = (url) => { setNavigationVisible(false) } router.events.on('routeChangeComplete', handleRouteChange) // If the component is unmounted, unsubscribe // from the event with the `off` method: return () => { router.events.off('routeChangeComplete', handleRouteChange) } }, []) return ( <> {currentPage} — Fela Main navigation setNavigationVisible(false)} extend={{ cursor: 'pointer', background: 'transparent', padding: 0, border: 0, right: 10, top: 10, position: 'fixed', font: 'inherit', }}> {Object.keys(toc).map((group) => ( {group} {Object.keys(toc[group]).map((page) => { const path = toc[group][page] if (typeof path === 'object') { return ( {page} {Object.keys(path).map((page) => ( ))} ) } return ( ) })} ))} setNavigationVisible(true)} extend={{ cursor: 'pointer', background: 'transparent', padding: 0, border: 0, font: 'inherit', }}> {currentPage} Edit {' '} on GitHub {children} ) }