Custom layouts
<Layout /> gives you a full doc shell, but some sections deserve custom framing. When you need to steer the markup yourself, import the primitives below inside _layout.mdx and arrange them however you like.
Navigation components
Import these helpers directly in the layout (or wire them globally through app/components/mdx.tsx):
<SubNavigation />reads the current directory, page context, andcontent/navigation.ymlto build a sidebar tree. Override the defaults withnavigation,heading, orariaLabelwhen you need a custom label or data source.<ContentNavigation />prints an on-page table of contents. With no props it derives headings from the current page. Passitems,heading, orheadingIdto take over the outline, and addcollapsibleif you want the built-in expand/collapse control. Leave it off for a static list.<ContentNavigationScript />handles sticky positioning, collapse state, and active-heading tracking. Include it once per layout (usually right after the nav markup). The script tags parent wrappers and injects any helper nodes it needs, so the HTML stays lean.
ContentNavigationScript runs once and keeps the navigation sticky, so the markup above is all you need. <ContentNavigation /> hydrates from the heading metadata captured during the MDX build; if the page has ## headings (or deeper) it will mirror the default <Layout />. When a page is short—or you need to curate the outline—pass your own items array.
Remember to render <ContentNavigationScript /> anywhere the TOC appears so the floating behavior works without hydrating React.