{# Documentation navigation. The primary icon rail mirrors the top-level `main` menu (Home + top bar sections). The secondary panel shows the active section's children from that menu, or the scoped documentation tree on /docs/ and /api/ pages. #} {% from 'chirpui/sidebar.html' import sidebar %} {% from 'chirpui/workspace_primitives.html' import filter_rail %} {% from 'partials/nav-icons.html' import section_icon_name %} {% def catalog_mark(title, href, index, icon_name=none) %} {% let _name = (icon_name ?? (section_icon_name(title, href) | trim)) | trim %} {% if _name %} {{ icon(_name, size=18) }} {% else %} {{ index }} {% end %} {% end %} {% def menu_rail_href(item) %} {% let item_href = item?.href ?? item?.url ?? '#' %} {% let item_children = item?.children ?? [] %} {% let item_identifier = item?.identifier ?? '' %} {% if item_href in ['#', '#dev'] and item_identifier == 'layouts' %} /layouts/ {% elif item_href in ['#', '#dev'] and item_identifier == 'dev' %} /dev/ {% elif item_href == '#' and item_children | length > 0 %} {{ (item_children[0]?.href ?? item_children[0]?.url ?? item_href) | trim }} {% elif item_href == '#dev' %} {% let resolved = item_href %} {% for child in item_children %} {% let child_href = child?.href ?? child?.url ?? '#' %} {% if child_href != '#' and not (child_href.startswith('http://') or child_href.startswith('https://')) %} {% let resolved = child_href %} {% end %} {% end %} {% if resolved == '#dev' and item_children | length > 0 %} {{ (item_children[0]?.href ?? item_children[0]?.url ?? resolved) | trim }} {% else %} {{ resolved | trim }} {% end %} {% else %} {{ item_href | trim }} {% end %} {% end %} {% def menu_nav_leaf(child) %} {% let child_title = child?.name ?? child?.title ?? 'Untitled' %} {% let child_href = child?.href ?? child?.url ?? '#' %} {% let child_current = current_path == child_href %} {% let child_active = child_href != '#' and (child_current or (child_href != '/' and current_path.startswith(child_href))) %} {% let child_icon = child?.icon ?? (section_icon_name(child_title, child_href) | trim) %} {% end %} {% def nav_type_icon(kind, branch=false) %} {% if branch %} {{ icon('folder', size=14) }} {% elif kind == 'api' %} {{ icon('file-code', size=14) }} {% else %} {{ icon('article', size=14) }} {% end %} {% end %} {% 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 is_branch_active = is_current or (item?.is_in_trail ?? false) or (item?.is_expanded ?? false) %} {% let has_children = item_children | length > 0 %} {% let item_key = (item_title ~ ' ' ~ item_href) | lower %} {% let item_kind = 'component' if 'component' in item_key else ('release' if 'release' in item_key else ('api' if ('api' in item_key or 'reference' in item_key) else ('pattern' if 'pattern' in item_key else ('guide' if ('guide' in item_key or 'doc' in item_key or 'start' in item_key or 'install' in item_key or 'theme' in item_key) else 'page')))) %} {% if has_children %} {% if depth > 0 %} {% let section_slug = (item_href if item_href else (item_title | lower)) | replace('/', '-') | replace(' ', '-') | replace('.', '-') | trim('-') %} {% let section_id = 'docs-nav-sect-' ~ section_slug %}
{% else %} {% end %} {% else %} {% if item_href %} {% else %} {% end %} {% end %} {% end %} {% let nav_page = page ?? none %} {% let is_autodoc = is_autodoc_page(nav_page) if (is_autodoc_page is defined and nav_page) else false %} {% let page_section = nav_page?._section %} {% let root_section = page_section?.root ?? none %} {% let current_path = catalog_current_path ?? nav_page?._path ?? nav_page?.href ?? '' %} {% let rail_items = get_menu_lang("main", _current_lang ?? current_lang()) ?? [] %} {% let use_doc_tree = nav_page and (current_path.startswith('/docs/') or current_path == '/docs/' or current_path.startswith('/api/') or current_path == '/api/') and root_section %} {% let in_layouts_section = current_path.startswith('/layouts/') or current_path == '/layouts/' or current_path.startswith('/blog/') or current_path == '/blog/' or current_path.startswith('/tutorial/') or current_path == '/tutorial/' or current_path.startswith('/tracks/') or current_path == '/tracks/' or current_path.startswith('/resume/') or current_path == '/resume/' or current_path.startswith('/notebook/') or current_path == '/notebook/' or current_path.startswith('/authors/') or current_path == '/authors/' or current_path.startswith('/changelog/') or current_path == '/changelog/' %} {% let in_dev_section = current_path.startswith('/dev/') or current_path == '/dev/' or current_path.startswith('/api/') or current_path == '/api/' %} {% let in_releases_section = current_path.startswith('/releases/') or current_path == '/releases/' %}