import { useState, useEffect, useRef } from "react"; import { useRouter } from "next/router"; import { TableOfContents } from "@urbit/foundation-design-system"; export default function ContentArea(props) { const [shortcut, setShortcut] = useState(""); const detectOS = () => { const agent = window.navigator.appVersion; if (agent.includes("Win")) { return "Ctrl+K"; } else if (agent.includes("Mac")) { return "⌘K"; } else if (agent.includes("Linux")) { return "Ctrl+K"; } }; useEffect(() => { setShortcut(detectOS()); }, []); const scrollBox = useRef(); const router = useRouter(); useEffect(() => { const handleRouteChange = () => { if (scrollBox.current === null) return; scrollBox.current.scrollTop = 0; }; router.events.on("routeChangeComplete", handleRouteChange); // If the component is unmounted, unsubscribe // from the event with the `off` method: return () => { router.events.off("routeChangeStart", handleRouteChange); }; }, []); return (
{props.breadcrumbs}

{props.title}

{props?.description && (

{props.description}

)}
{props.children}
{!props?.disableToC && ( )}
); }