{# ================================================================================ Documentation Navigation Component (Kida-Native) ================================================================================ Hierarchical sidebar navigation for documentation sites. Uses pre-computed NavTree for optimal performance. KIDA FEATURES USED: - {% def %} for recursive macro (3x faster than {% include %}) - {% let %} for template-scoped variables - Optional chaining (?.) for null-safe access - Null coalescing (??) for smart defaults - {% match %} for node type dispatch - {% spaceless %} for clean HTML output FEATURES: - Hierarchical tree structure via NavTree API - Active page highlighting (automatic via NavNodeProxy) - Active trail marking (automatic via NavTreeContext) - Version-aware filtering (automatic via NavTreeCache) - Keyboard accessible - Section icons from frontmatter USAGE: {% include 'partials/docs-nav.html' %} ================================================================================ #} {# Control icon visibility - defaults to true if not passed in context #} {% let show_nav_icons = show_nav_icons ?? true %} {# ============================================================================= NAV NODE MACRO - Recursive navigation node renderer Replaces the previous docs-nav-node.html include pattern. Macros are compiled once and called as functions, eliminating the per-call overhead of {% include %} (context copy, template lookup). ============================================================================= #} {% def nav_node(item, depth=0) %} {# Extract values once with null-safe access #} {% let item_title = item?.title ?? 'Untitled' %} {% let item_icon = item?.icon ?? '' %} {% let item_href = item?.href ?? '' %} {% let item_children = item?.children ?? [] %} {% let is_current = item?.is_current ?? false %} {% let is_in_trail = item?.is_in_trail ?? false %} {% let is_section = item?.is_section ?? false %} {% let has_children = item_children | length > 0 %} {% match has_children, depth %} {# ===== ROOT NODE (depth 0) - Static header, no toggle ===== #} {% case true, 0 %}