{# This overrides the nav-item partial from mkdocs-material v9.6.17 #} {# https://github.com/squidfunk/mkdocs-material/blob/c89a66bf39bb7f472e925753367ff8e464e0d683/src/templates/partials/nav-item.html #} {# Majority of the file is the original, so our changes are highlighted #} {# with `OUR CHANGES START` and `OUR CHANGES END` #} {% macro render_status(nav_item, type) %} {% set class = "md-status md-status--" ~ type %} {% if config.extra.status and config.extra.status[type] %} {% else %} {% endif %} {% 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 %} {# Insert line break between group name and title #} {# E.g. `Documentation: API Reference` -> `Documentation:
API Reference` #} {% if ": " in ref.title %} {% set parts = ref.title.split(": ", 1) %} {% set title = parts[0] ~ ":
" | safe ~ parts[1] %} {% else %} {% set title = ref.title %} {% endif %} {{ title }} {% if nav_item.meta and nav_item.meta.subtitle %}
{{ nav_item.meta.subtitle }} {% endif %}
{% if nav_item.meta and nav_item.meta.status %} {{ render_status(nav_item, nav_item.meta.status) }} {% 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 %}
  • {% if not is_pruned %} {% set checked = "checked" if nav_item.active %} {% if "navigation.expand" in features and not checked %} {% set indeterminate = "md-toggle--indeterminate" %} {% endif %} {% if not index %} {% set tabindex = "0" if not is_section %} {% else %} {% set class = "md-nav__link--active" if index == page %} {% endif %} {% else %} {{ render_pruned(nav_item) }} {% endif %}
  • {% elif nav_item == page %}
  • {% set toc = page.toc %} {% set first = toc | first %} {% if first and first.level == 1 %} {% set toc = first.children %} {% endif %} {% if toc %} {% endif %} {{ render_content(nav_item) }} {% if toc %} {% include "partials/toc.html" %} {% endif %}
  • {% else %}
  • {{ render_content(nav_item) }}
  • {% endif %} {% endmacro %}