zudo-doc
GitHub repository

Type to search...

to open search from anywhere

SiteTreeNav

Created Mar 14, 2026Updated Jun 7, 2026Takeshi Takatsudo

A sitemap-like grid component that displays the full documentation tree with expandable categories.

Overview

SiteTreeNav is a Preact 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

This component is not directly available in MDX content. It requires server-side data fetching, so it must be imported in a zfb page module. The live demo below uses SiteTreeNavDemo, a wrapper registered as a global MDX component.

Live Example

Below is SiteTreeNav rendered with the full documentation tree (same as the home page):

Usage

SiteTreeNav is used in pages/index.tsx to display the home page sitemap:

// pages/index.tsx
import { buildNavTree, groupSatelliteNodes } from "@/utils/docs";
import { getCategoryOrder } from "@/utils/nav-scope";
import SiteTreeNav from "@/components/site-tree-nav";
import { resolveNavSource } from "./lib/_nav-source-docs";
import { defaultLocale } from "@/config/i18n";

export default function IndexPage() {
  const locale = defaultLocale;
  const { navDocs, categoryMeta } = resolveNavSource(locale, undefined);
  const tree = buildNavTree(navDocs, locale, categoryMeta);
  const categoryOrder = getCategoryOrder();
  const groupedTree = groupSatelliteNodes(tree, categoryOrder);

  return (
    <SiteTreeNav
      tree={groupedTree}
      categoryOrder={categoryOrder}
      categoryIgnore={["inbox", "develop"]}
    />
  );
}

The component uses Preact state for expand/collapse interactivity, so it hydrates on the client through zfb's island runtime.

Props

PropTypeDefaultDescription
treeNavNode[](required)The navigation tree built from content collection
categoryOrderstring[]Custom ordering of top-level categories
categoryIgnorestring[]Category slugs to hide from the tree
ariaLabelstring"Site index"Accessibility label for the nav element

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 screens

  • Expandable categories — each category card is collapsible, open by default

  • Hierarchical tree — nested pages are indented with connector lines showing the tree structure

  • Category 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

The component is defined at src/components/site-tree-nav.tsx.

Revision History

Takeshi TakatsudoCreated: 2026-03-14T21:08:33+09:00Updated: 2026-06-07T16:19:05+09:00

AI Assistant

Ask a question about the documentation.