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
-#}
{% set features = config.theme.features or [] %}
{% macro do_nav_item(nav_item, path, level) %}
{% set class = "md-nav__item" %}
{% if nav_item.active %}
{% macro render_nav_item(nav_item, path, level) %}
{% set class = "md-nav__item" %}
{% if nav_item.active %}
{% set class = class ~ " md-nav__item--active" %}
{% endif %}
{% if nav_item.children %}
{% endif %}
{% if nav_item.children %}
{% if "navigation.sections" in features and level == 1 + (
"navigation.tabs" in features
) %}
@ -32,12 +32,16 @@
<ul class="md-nav__list" data-md-scrollfix>
{% set base = path %}
{% 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 %}
</ul>
</nav>
</li>
{% elif nav_item == page %}
{% elif nav_item == page %}
<li class="{{ class }}">
{% set toc = page.toc %}
<input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc">
@ -57,12 +61,12 @@
{% include "partials/toc.html" %}
{% endif %}
</li>
{% else %}
{% else %}
<li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="md-nav__link">
{{ nav_item.title }}
</a>
</li>
{% endif %}
{% endif %}
{% 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 -->
{% set features = config.theme.features or [] %}
<!-- Wrap everything into a macro to reduce file roundtrips -->
{% macro do_nav_item(nav_item, path, level) %}
<!-- Wrap everything into a macro to reduce file roundtrips (see #2213) -->
{% macro render_nav_item(nav_item, path, level) %}
<!-- Determine class according to state -->
{% set class = "md-nav__item" %}
{% if nav_item.active %}
<!-- Determine class according to state -->
{% set class = "md-nav__item" %}
{% if nav_item.active %}
{% set class = class ~ " md-nav__item--active" %}
{% endif %}
{% endif %}
<!-- Main navigation item with nested items -->
{% if nav_item.children %}
<!-- Main navigation item with nested items -->
{% if nav_item.children %}
<!-- Determine whether to render item as a section -->
{% if "navigation.sections" in features and level == 1 + (
@ -85,14 +85,18 @@
<!-- Render nested item list -->
{% set base = path %}
{% 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 %}
</ul>
</nav>
</li>
<!-- Currently active page -->
{% elif nav_item == page %}
<!-- Currently active page -->
{% elif nav_item == page %}
<li class="{{ class }}">
{% set toc = page.toc %}
@ -129,15 +133,14 @@
{% endif %}
</li>
<!-- Main navigation item -->
{% else %}
<!-- Main navigation item -->
{% else %}
<li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="md-nav__link">
{{ nav_item.title }}
</a>
</li>
{% endif %}
{% endif %}
{% endmacro %}
{{ do_nav_item(nav_item, path, level) }}
{{ render_nav_item(nav_item, path, level) }}