SiteTreeNav
A sitemap-like grid component that displays the full documentation tree with expandable categories.
Overview
SiteTreeNav is a client island component that renders a responsive grid of expandable category cards showing the full documentation tree. It provides a sitemap-style index of all documentation pages, with categories that can be expanded and collapsed.
Info
SiteTreeNav is directly available in MDX content — it's registered as a global MDX tag, so <SiteTreeNav /> works with no import. The SiteTreeNavDemo tag used in the live example below resolves to the exact same self-fetching wrapper; the two names are interchangeable in MDX.
This is a different component from the raw, tree-prop-driven SiteTreeNav shipped at @takazudo/ — that one takes no data by itself and is meant for a page module that already has a nav tree to pass in. See Usage below for both.
Live Example
Below is SiteTreeNav rendered with the full documentation tree (same as the home page):
Usage
In MDX content
Use the global MDX tag directly in any .mdx file — no import needed:
<SiteTreeNav />No props are required. It self-fetches the current locale's docs collection, builds the nav tree, and renders the interactive island — the same wrapper used by SiteTreeNavDemo above.
Categories hidden from the tree come from siteTreeNavIgnore in zfb.config.ts. siteTreeNavSecondary is home-page only and is not applied by this component, so categories listed there still appear in its tree.
Categories listed in siteTreeNavInitiallyCollapsed start closed in both MDX aliases and the package-owned home pages. The category link and toggle remain visible, and visitors can expand the descendants.
In a page module
A page module that already has a tree in hand (e.g. built via buildNavTree + groupSatelliteNodes) can import the raw, tree-prop-driven component instead:
import { SiteTreeNav } from "@takazudo/zudo-doc/site-tree-nav-island";
export default function IndexPage() {
return (
<SiteTreeNav
tree={tree}
categoryOrder={categoryOrder}
categoryIgnore={["inbox", "develop"]}
initiallyCollapsedCategorySlugs={["zudo-wind/utilities"]}
/>
);
}The raw island's categoryIgnore prop is the per-call equivalent of the site-wide siteTreeNavIgnore setting; the package home page and the MDX tag pass that setting here.
This repository's own home page (pages/) doesn't call this island directly — it hands the resolved locale to prepareHomeData() and passes the result to HomePageView, both from @takazudo/, which renders SiteTreeNav internally alongside the hero and tag section.
The component uses signals for expand/collapse interactivity, so it hydrates on the client through zfb's island runtime.
Props
Props below apply to the raw SiteTreeNav island (@takazudo/). The MDX tag takes no data props — it resolves tree/categoryOrder itself for the current locale, and only forwards the optional ariaLabel, variant and idPrefix.
| Prop | Type | Default | Description |
|---|---|---|---|
tree | NavNode[] | (required) | The navigation tree built from content collection |
categoryOrder | string[] | — | Custom ordering of top-level categories |
categoryIgnore | string[] | — | Category slugs to hide from the tree (the package home page and the MDX tag pass siteTreeNavIgnore here) |
initiallyCollapsedCategorySlugs | string[] | [] | Exact full category slugs at any depth that should start collapsed |
ariaLabel | string | "Site index" | Accessibility label for the nav element |
variant | "default" | "described" | "default" | "described" adds descriptions and per-category document counts (see Described variant) |
countLabels | { one: string; other: string } | English | Described-variant count templates with a {count} placeholder; the MDX tag and home page pass the translated labels |
idPrefix | string | "zd-site-tree" | Prefix for the disclosure target ids; give each tree on a page its own value |
Described variant
variant="described" keeps the same tree and interactions and adds the descriptions the documents already have, plus each category's document count. A category or document without a description shows no empty space. Cards use a grid with columns of about 22rem.
<SiteTreeNav variant="described" idPrefix="described" />When the tree has a single category and its box is at least 48.75rem wide, the category summary moves into its own column (up to 20rem) beside the document tree; narrower boxes stack the summary above the tree. The switch follows the width of the component, not of the window, so the same tree stacks inside a narrow column on a wide screen. The home page sections setting uses this variant.
Category covers
A top-level section can show a picture on its card in the home page site index. Add the cover frontmatter field to that section's index.mdx:
---
title: Guides
sidebar_position: 2
cover: /img/covers/guides.png
---Where it shows. Only on the package home pages (
/and each locale home), in the site index of both the classic sitemap block and ahome.sectionssite-treesection. The<SiteTreeNav />and<SiteTreeNavDemo />tags in a document, like the examples on this page, do not show covers.Which cards. Only top-level sections. A
coverdeeper in the tree, such as on a nested category'sindex.mdx, is ignored. A section hidden bysiteTreeNavIgnoreor moved to the secondary row bysiteTreeNavSecondaryhas no card, so its cover does not show either. Cards without a cover look as they always do.The picture. It sits at the top of the card, flush with the card border, in a 1200:630 box that is reserved before the picture loads. It is cropped to fill that box (
object-fit: cover), so a 1200 × 630 picture shows whole. It loads lazily and is decorative (alt=""), because the section title is printed right below it.Path. A root-absolute site path, usually a file in
public/; the sitebaseis prefixed for you. External URLs,/paths, backslashes and control characters fail frontmatter validation at build time./ Default and described variants. The cover is the same in both: the first thing in the card, above the section title. In the described variant the description and document count follow below the title as usual, and when a lone section splits into a summary column and a tree column, the cover stays above both columns, across the full card width.
The raw island at @takazudo/ takes the picture from a coverHref field on a top-level node of tree: a ready-to-use URL that the package home page builds from cover and base. For complete home page configurations that use covers, see the Catalogue arrangement.
Features
Responsive grid layout — uses
repeat(auto-fill, minmax(min(18rem, 100%), 1fr))to adapt from single-column on mobile to multi-column on wider screensExpandable categories — each category card is collapsible, open by default
Initial collapse — a selected category starts closed in server HTML and remains interactive after hydration; other categories stay open
Hierarchical tree — nested pages are indented with dashed connector lines. Every rail sits on the centre of the 1.75rem marker/toggle slot, so a category's chevron icon lines up with the rail of its tree, a nested rail starts at the bottom centre of its parent's boxed toggle, branches meet the first text line of multi-line rows, and the last rail stops at its branch. A stacked category keeps a short lead-in above its first branch; the split single-category layout starts the rail at the first branch
Separate link and toggle — a category with a page links to it and has its own boxed disclosure button; a category without a page toggles from its label. Each toggle names its target with
aria-controls, and collapsed children leave the keyboard and accessibility orderCategory links — top-level categories display an arrow icon and link to their index page
Leaf pages — individual doc pages are rendered as clickable links
Source
SiteTreeNav ships from the @takazudo/zudo-doc package — import the raw island from @takazudo/ for page-module usage. (Within this repository the island source lives at packages/.) The <SiteTreeNav /> / <SiteTreeNavDemo /> MDX tags are wired automatically via the package-owned routes (packageOwnedRoutes, on by default) — there is no project file to maintain for them.