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,67 +2,71 @@
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 %}
{% if nav_item.children %}
{% if "navigation.sections" in features and level == 1 + (
"navigation.tabs" in features
) %}
{% set class = class ~ " md-nav__item--section" %}
{% endif %} {% endif %}
<li class="{{ class }} md-nav__item--nested"> {% if nav_item.children %}
{% set checked = "checked" if nav_item.active %} {% if "navigation.sections" in features and level == 1 + (
{% if "navigation.expand" in features and not checked %} "navigation.tabs" in features
<input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" data-md-state="indeterminate" type="checkbox" id="{{ path }}" checked> ) %}
{% else %} {% set class = class ~ " md-nav__item--section" %}
<input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" type="checkbox" id="{{ path }}" {{ checked }}>
{% endif %} {% endif %}
<label class="md-nav__link" for="{{ path }}"> <li class="{{ class }} md-nav__item--nested">
{{ nav_item.title }} {% set checked = "checked" if nav_item.active %}
<span class="md-nav__icon md-icon"></span> {% if "navigation.expand" in features and not checked %}
</label> <input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" data-md-state="indeterminate" type="checkbox" id="{{ path }}" checked>
<nav class="md-nav" aria-label="{{ nav_item.title }}" data-md-level="{{ level }}"> {% else %}
<label class="md-nav__title" for="{{ path }}"> <input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" type="checkbox" id="{{ path }}" {{ checked }}>
<span class="md-nav__icon md-icon"></span> {% endif %}
{{ nav_item.title }} <label class="md-nav__link" for="{{ path }}">
</label>
<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) }}
{% endfor %}
</ul>
</nav>
</li>
{% 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">
{% if toc | first is defined and "\x3ch1 id=" in page.content %}
{% set toc = (toc | first).children %}
{% endif %}
{% if toc | first is defined %}
<label class="md-nav__link md-nav__link--active" for="__toc">
{{ nav_item.title }} {{ nav_item.title }}
<span class="md-nav__icon md-icon"></span> <span class="md-nav__icon md-icon"></span>
</label> </label>
{% endif %} <nav class="md-nav" aria-label="{{ nav_item.title }}" data-md-level="{{ level }}">
<a href="{{ nav_item.url | url }}" class="md-nav__link md-nav__link--active"> <label class="md-nav__title" for="{{ path }}">
{{ nav_item.title }} <span class="md-nav__icon md-icon"></span>
</a> {{ nav_item.title }}
{% if toc | first is defined %} </label>
{% include "partials/toc.html" %} <ul class="md-nav__list" data-md-scrollfix>
{% endif %} {% set base = path %}
</li> {% for nav_item in nav_item.children %}
{% else %} {{ render_nav_item(
<li class="{{ class }}"> nav_item,
<a href="{{ nav_item.url | url }}" class="md-nav__link"> path = base ~ "-" ~ loop.index,
{{ nav_item.title }} level = level + 1)
</a> }}
</li> {% endfor %}
{% endif %} </ul>
</nav>
</li>
{% 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">
{% if toc | first is defined and "\x3ch1 id=" in page.content %}
{% set toc = (toc | first).children %}
{% endif %}
{% if toc | first is defined %}
<label class="md-nav__link md-nav__link--active" for="__toc">
{{ nav_item.title }}
<span class="md-nav__icon md-icon"></span>
</label>
{% endif %}
<a href="{{ nav_item.url | url }}" class="md-nav__link md-nav__link--active">
{{ nav_item.title }}
</a>
{% if toc | first is defined %}
{% include "partials/toc.html" %}
{% endif %}
</li>
{% else %}
<li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="md-nav__link">
{{ nav_item.title }}
</a>
</li>
{% endif %}
{% endmacro %} {% endmacro %}
{{ do_nav_item(nav_item, path, level) }} {{ render_nav_item(nav_item, path, level) }}

View File

@ -23,121 +23,124 @@
<!-- 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 %}
<!-- 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 + (
"navigation.tabs" in features
) %}
{% set class = class ~ " md-nav__item--section" %}
{% endif %} {% endif %}
<!-- Render item with nested items --> <!-- Main navigation item with nested items -->
<li class="{{ class }} md-nav__item--nested"> {% if nav_item.children %}
<!-- Active checkbox expands items contained within nested section --> <!-- Determine whether to render item as a section -->
{% set checked = "checked" if nav_item.active %} {% if "navigation.sections" in features and level == 1 + (
{% if "navigation.expand" in features and not checked %} "navigation.tabs" in features
<input ) %}
class="md-nav__toggle md-toggle" {% set class = class ~ " md-nav__item--section" %}
data-md-toggle="{{ path }}"
data-md-state="indeterminate"
type="checkbox"
id="{{ path }}"
checked
/>
{% else %}
<input
class="md-nav__toggle md-toggle"
data-md-toggle="{{ path }}"
type="checkbox"
id="{{ path }}"
{{ checked }}
/>
{% endif %} {% endif %}
<!-- Expand active pages --> <!-- Render item with nested items -->
<label class="md-nav__link" for="{{ path }}"> <li class="{{ class }} md-nav__item--nested">
{{ nav_item.title }}
<span class="md-nav__icon md-icon"></span>
</label>
<nav
class="md-nav"
aria-label="{{ nav_item.title }}"
data-md-level="{{ level }}"
>
<label class="md-nav__title" for="{{ path }}">
<span class="md-nav__icon md-icon"></span>
{{ nav_item.title }}
</label>
<ul class="md-nav__list" data-md-scrollfix>
<!-- Render nested item list --> <!-- Active checkbox expands items contained within nested section -->
{% set base = path %} {% set checked = "checked" if nav_item.active %}
{% for nav_item in nav_item.children %} {% if "navigation.expand" in features and not checked %}
{{ do_nav_item(nav_item, path = base ~ "-" ~ loop.index, level = level + 1) }} <input
{% endfor %} class="md-nav__toggle md-toggle"
</ul> data-md-toggle="{{ path }}"
</nav> data-md-state="indeterminate"
</li> type="checkbox"
id="{{ path }}"
checked
/>
{% else %}
<input
class="md-nav__toggle md-toggle"
data-md-toggle="{{ path }}"
type="checkbox"
id="{{ path }}"
{{ checked }}
/>
{% endif %}
<!-- Currently active page --> <!-- Expand active pages -->
{% elif nav_item == page %} <label class="md-nav__link" for="{{ path }}">
<li class="{{ class }}">
{% set toc = page.toc %}
<!-- Active checkbox expands items contained within nested section -->
<input
class="md-nav__toggle md-toggle"
data-md-toggle="toc"
type="checkbox"
id="__toc"
/>
<!-- Hack: see partials/toc.html for more information -->
{% if toc | first is defined and "\x3ch1 id=" in page.content %}
{% set toc = (toc | first).children %}
{% endif %}
<!-- Render table of contents, if not empty -->
{% if toc | first is defined %}
<label class="md-nav__link md-nav__link--active" for="__toc">
{{ nav_item.title }} {{ nav_item.title }}
<span class="md-nav__icon md-icon"></span> <span class="md-nav__icon md-icon"></span>
</label> </label>
{% endif %} <nav
<a class="md-nav"
href="{{ nav_item.url | url }}" aria-label="{{ nav_item.title }}"
class="md-nav__link md-nav__link--active" data-md-level="{{ level }}"
> >
{{ nav_item.title }} <label class="md-nav__title" for="{{ path }}">
</a> <span class="md-nav__icon md-icon"></span>
{{ nav_item.title }}
</label>
<ul class="md-nav__list" data-md-scrollfix>
<!-- Show table of contents --> <!-- Render nested item list -->
{% if toc | first is defined %} {% set base = path %}
{% include "partials/toc.html" %} {% for nav_item in nav_item.children %}
{% endif %} {{ render_nav_item(
</li> nav_item,
path = base ~ "-" ~ loop.index,
level = level + 1)
}}
{% endfor %}
</ul>
</nav>
</li>
<!-- Main navigation item --> <!-- Currently active page -->
{% else %} {% elif nav_item == page %}
<li class="{{ class }}"> <li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="md-nav__link"> {% set toc = page.toc %}
{{ nav_item.title }}
</a>
</li>
{% endif %}
<!-- Active checkbox expands items contained within nested section -->
<input
class="md-nav__toggle md-toggle"
data-md-toggle="toc"
type="checkbox"
id="__toc"
/>
<!-- Hack: see partials/toc.html for more information -->
{% if toc | first is defined and "\x3ch1 id=" in page.content %}
{% set toc = (toc | first).children %}
{% endif %}
<!-- Render table of contents, if not empty -->
{% if toc | first is defined %}
<label class="md-nav__link md-nav__link--active" for="__toc">
{{ nav_item.title }}
<span class="md-nav__icon md-icon"></span>
</label>
{% endif %}
<a
href="{{ nav_item.url | url }}"
class="md-nav__link md-nav__link--active"
>
{{ nav_item.title }}
</a>
<!-- Show table of contents -->
{% if toc | first is defined %}
{% include "partials/toc.html" %}
{% endif %}
</li>
<!-- Main navigation item -->
{% else %}
<li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="md-nav__link">
{{ nav_item.title }}
</a>
</li>
{% endif %}
{% endmacro %} {% endmacro %}
{{ do_nav_item(nav_item, path, level) }} {{ render_nav_item(nav_item, path, level) }}