{#-
Adapted from Zensical 0.0.59, partials/nav-item.html.
Status output is omitted; native titles and navigation controls are retained.
Copyright (c) 2025-2026 Zensical and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-#}
{% macro render_title(nav_item, ref) %}
{% set ref = ref or nav_item %}
{{ ref.title or nav_item.title }}
{% endmacro %}
{% macro render_content(nav_item, ref) %}
{% set ref = ref or nav_item %}
{% if nav_item.meta and nav_item.meta.icon %}
{% include ".icons/" ~ nav_item.meta.icon ~ ".svg" %}
{% endif %}
{{ render_title(nav_item, ref) }}
{% if nav_item.meta and nav_item.meta.subtitle %}
{{ nav_item.meta.subtitle }}
{% endif %}
{% endmacro %}
{% macro render_pruned(nav_item, ref) %}
{% set ref = ref or nav_item %}
{% set first = nav_item.children | first %}
{% if first and first.children %}
{{ render_pruned(first, ref) }}
{% else %}
{{ render_content(ref) }}
{% if nav_item.children | length > 0 %}
{% endif %}
{% endif %}
{% endmacro %}
{% macro render(nav_item, path, level, parent) %}
{% set class = "md-nav__item" %}
{% if nav_item.active %}
{% set class = class ~ " md-nav__item--active" %}
{% endif %}
{% if nav_item.pages %}
{% if page in nav_item.pages %}
{% set nav_item = page %}
{% endif %}
{% endif %}
{% if nav_item.children %}
{% set _ = namespace(index = none) %}
{% if "navigation.indexes" in features %}
{% for item in nav_item.children %}
{% if item.is_index and _.index is none %}
{% set _.index = item %}
{% endif %}
{% endfor %}
{% endif %}
{% set index = _.index %}
{% if "navigation.tabs" in features %}
{% if level == 1 and nav_item.active %}
{% set class = class ~ " md-nav__item--section" %}
{% set is_section = true %}
{% endif %}
{% if "navigation.sections" in features %}
{% if level == 2 and parent.active %}
{% set class = class ~ " md-nav__item--section" %}
{% set is_section = true %}
{% endif %}
{% endif %}
{% elif "navigation.sections" in features %}
{% if level == 1 %}
{% set class = class ~ " md-nav__item--section" %}
{% set is_section = true %}
{% endif %}
{% endif %}
{% if "navigation.prune" in features %}
{% if not is_section and not nav_item.active %}
{% set class = class ~ " md-nav__item--pruned" %}
{% set is_pruned = true %}
{% endif %}
{% endif %}