{# Documentation navigation. The tree still comes from Bengal's NavTree context, but the emitted chrome uses Chirp UI sidebar primitives instead of a bespoke docs-nav class system. #} {% from 'chirpui/sidebar.html' import sidebar, sidebar_link, sidebar_section %} {% def nav_node(item, depth=0) %} {% let item_title = item?.title ?? 'Untitled' %} {% let item_href = item?.href ?? '' %} {% let item_children = item?.children ?? [] %} {% let is_current = item?.is_current ?? false %} {% let has_children = item_children | length > 0 %} {% if has_children %} {% call sidebar_section(item_title, collapsible=depth > 0, cls='chirp-theme-docs-nav__section chirp-theme-docs-nav__section--depth-' ~ depth) %} {% if item_href %} {{ sidebar_link(item_href | absolute_url, item_title, active=is_current, boost=false, cls='chirp-theme-docs-nav__branch-link') }} {% end %} {% for child in item_children %} {{ nav_node(child, depth + 1) }} {% end %} {% end %} {% else %} {% if item_href %} {{ sidebar_link(item_href | absolute_url, item_title, active=is_current, boost=false, cls='chirp-theme-docs-nav__leaf-link') }} {% else %} {{ item_title }} {% end %} {% end %} {% end %} {% let is_autodoc = is_autodoc_page(page) if is_autodoc_page is defined else false %} {% let page_section = page?._section %} {% let root_section = page_section?.root ?? none %} {% let current_path = page?.href ?? page?._path ?? '' %} {% call sidebar(cls='chirp-theme-docs-nav', current_path=current_path) %} {% slot header %} {% unless is_autodoc %} {% include 'partials/version-selector.html' %} {% end %} {% end %} {% if root_section %} {% let nav_context = get_nav_context(page, root_section=root_section) %} {% with nav_context?.root as root_item %} {{ nav_node(root_item, 0) }} {% end %} {% else %} {% let nav_items = get_nav_tree(page) ?? [] %} {% for item in nav_items %} {{ nav_node(item, 0) }} {% end %} {% end %} {% end %}