Formatting

This commit is contained in:
squidfunk 2021-01-17 10:41:10 +01:00
parent 81a13f6bc6
commit ebd8839a03
2 changed files with 167 additions and 160 deletions

View File

@ -2,12 +2,12 @@
This file was automatically generated - do not edit This file was automatically generated - do not edit
-#} -#}
{% set features = config.theme.features or [] %} {% set features = config.theme.features or [] %}
{% macro do_nav_item(nav_item, path, level) %} {% macro render_nav_item(nav_item, path, level) %}
{% set class = "md-nav__item" %} {% set class = "md-nav__item" %}
{% if nav_item.active %} {% if nav_item.active %}
{% set class = class ~ " md-nav__item--active" %} {% set class = class ~ " md-nav__item--active" %}
{% endif %} {% endif %}
{% if nav_item.children %} {% if nav_item.children %}
{% if "navigation.sections" in features and level == 1 + ( {% if "navigation.sections" in features and level == 1 + (
"navigation.tabs" in features "navigation.tabs" in features
) %} ) %}
@ -32,12 +32,16 @@
<ul class="md-nav__list" data-md-scrollfix> <ul class="md-nav__list" data-md-scrollfix>
{% set base = path %} {% set base = path %}
{% for nav_item in nav_item.children %} {% for nav_item in nav_item.children %}
{{ do_nav_item(nav_item, path = base ~ "-" ~ loop.index, level = level + 1) }} {{ render_nav_item(
nav_item,
path = base ~ "-" ~ loop.index,
level = level + 1)
}}
{% endfor %} {% endfor %}
</ul> </ul>
</nav> </nav>
</li> </li>
{% elif nav_item == page %} {% elif nav_item == page %}
<li class="{{ class }}"> <li class="{{ class }}">
{% set toc = page.toc %} {% set toc = page.toc %}
<input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc"> <input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc">
@ -57,12 +61,12 @@
{% include "partials/toc.html" %} {% include "partials/toc.html" %}
{% endif %} {% endif %}
</li> </li>
{% else %} {% else %}
<li class="{{ class }}"> <li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="md-nav__link"> <a href="{{ nav_item.url | url }}" class="md-nav__link">
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ do_nav_item(nav_item, path, level) }} {{ render_nav_item(nav_item, path, level) }}

View File

@ -23,17 +23,17 @@
<!-- Retrieve features from configuration --> <!-- Retrieve features from configuration -->
{% set features = config.theme.features or [] %} {% set features = config.theme.features or [] %}
<!-- Wrap everything into a macro to reduce file roundtrips --> <!-- Wrap everything into a macro to reduce file roundtrips (see #2213) -->
{% macro do_nav_item(nav_item, path, level) %} {% macro render_nav_item(nav_item, path, level) %}
<!-- Determine class according to state --> <!-- Determine class according to state -->
{% set class = "md-nav__item" %} {% set class = "md-nav__item" %}
{% if nav_item.active %} {% if nav_item.active %}
{% set class = class ~ " md-nav__item--active" %} {% set class = class ~ " md-nav__item--active" %}
{% endif %} {% endif %}
<!-- Main navigation item with nested items --> <!-- Main navigation item with nested items -->
{% if nav_item.children %} {% if nav_item.children %}
<!-- Determine whether to render item as a section --> <!-- Determine whether to render item as a section -->
{% if "navigation.sections" in features and level == 1 + ( {% if "navigation.sections" in features and level == 1 + (
@ -85,14 +85,18 @@
<!-- Render nested item list --> <!-- Render nested item list -->
{% set base = path %} {% set base = path %}
{% for nav_item in nav_item.children %} {% for nav_item in nav_item.children %}
{{ do_nav_item(nav_item, path = base ~ "-" ~ loop.index, level = level + 1) }} {{ render_nav_item(
nav_item,
path = base ~ "-" ~ loop.index,
level = level + 1)
}}
{% endfor %} {% endfor %}
</ul> </ul>
</nav> </nav>
</li> </li>
<!-- Currently active page --> <!-- Currently active page -->
{% elif nav_item == page %} {% elif nav_item == page %}
<li class="{{ class }}"> <li class="{{ class }}">
{% set toc = page.toc %} {% set toc = page.toc %}
@ -129,15 +133,14 @@
{% endif %} {% endif %}
</li> </li>
<!-- Main navigation item --> <!-- Main navigation item -->
{% else %} {% else %}
<li class="{{ class }}"> <li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="md-nav__link"> <a href="{{ nav_item.url | url }}" class="md-nav__link">
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ do_nav_item(nav_item, path, level) }} {{ render_nav_item(nav_item, path, level) }}