mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-27 17:00:54 +01:00
Simplified conditionals in templates
This commit is contained in:
parent
a46b42c5e2
commit
acc4a273c4
@ -7,11 +7,8 @@
|
||||
{% endif %}
|
||||
{% if nav_item.children %}
|
||||
<li class="{{ class }} md-nav__item--nested">
|
||||
{% if nav_item.active %}
|
||||
<input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" type="checkbox" id="{{ path }}" checked>
|
||||
{% else %}
|
||||
<input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" type="checkbox" id="{{ path }}">
|
||||
{% endif %}
|
||||
{% set checked = "checked" if nav_item.active %}
|
||||
<input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" type="checkbox" id="{{ path }}" {{ checked }}>
|
||||
<label class="md-nav__link" for="{{ path }}">
|
||||
{{ nav_item.title }}
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
|
@ -3,15 +3,13 @@
|
||||
-#}
|
||||
{% if nav_item.is_homepage or nav_item.url == "index.html" %}
|
||||
<li class="md-tabs__item">
|
||||
{% set class = "md-tabs__link" %}
|
||||
{% if not page.ancestors | length and nav | selectattr("url", page.url) %}
|
||||
<a href="{{ nav_item.url | url }}" class="md-tabs__link md-tabs__link--active">
|
||||
{{ nav_item.title }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ nav_item.url | url }}" class="md-tabs__link">
|
||||
{{ nav_item.title }}
|
||||
</a>
|
||||
{% set class = "md-tabs__link md-tabs__link--active" %}
|
||||
{% endif %}
|
||||
<a href="{{ nav_item.url | url }}" class="{{ class }}">
|
||||
{{ nav_item.title }}
|
||||
</a>
|
||||
</li>
|
||||
{% elif nav_item.children and nav_item.children | length > 0 %}
|
||||
{% set title = title | default(nav_item.title) %}
|
||||
@ -20,15 +18,13 @@
|
||||
{% include "partials/tabs-item.html" %}
|
||||
{% else %}
|
||||
<li class="md-tabs__item">
|
||||
{% set class = "md-tabs__link" %}
|
||||
{% if nav_item.active %}
|
||||
<a href="{{ (nav_item.children | first).url | url }}" class="md-tabs__link md-tabs__link--active">
|
||||
{{ title }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ (nav_item.children | first).url | url }}" class="md-tabs__link">
|
||||
{{ title }}
|
||||
</a>
|
||||
{% set class = "md-tabs__link md-tabs__link--active" %}
|
||||
{% endif %}
|
||||
<a href="{{ (nav_item.children | first).url | url }}" class="{{ class }}">
|
||||
{{ title }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% elif nav_item.url.startswith("http") %}
|
||||
|
@ -31,22 +31,14 @@
|
||||
<li class="{{ class }} md-nav__item--nested">
|
||||
|
||||
<!-- Active checkbox expands items contained within nested section -->
|
||||
{% if nav_item.active %}
|
||||
<input
|
||||
class="md-nav__toggle md-toggle"
|
||||
data-md-toggle="{{ path }}"
|
||||
type="checkbox"
|
||||
id="{{ path }}"
|
||||
checked
|
||||
/>
|
||||
{% else %}
|
||||
<input
|
||||
class="md-nav__toggle md-toggle"
|
||||
data-md-toggle="{{ path }}"
|
||||
type="checkbox"
|
||||
id="{{ path }}"
|
||||
/>
|
||||
{% endif %}
|
||||
{% set checked = "checked" if nav_item.active %}
|
||||
<input
|
||||
class="md-nav__toggle md-toggle"
|
||||
data-md-toggle="{{ path }}"
|
||||
type="checkbox"
|
||||
id="{{ path }}"
|
||||
{{ checked }}
|
||||
/>
|
||||
|
||||
<!-- Expand active pages -->
|
||||
<label class="md-nav__link" for="{{ path }}">
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
{% import "partials/language.html" as lang with context %}
|
||||
|
||||
<!-- Support for mkdocs-git-revision-date-localized-plugin -->
|
||||
<!-- Last updated date -->
|
||||
{% set label = lang.t("source.revision.date") %}
|
||||
<hr />
|
||||
<div class="md-source-date">
|
||||
|
@ -23,18 +23,13 @@
|
||||
<!-- Home page -->
|
||||
{% if nav_item.is_homepage or nav_item.url == "index.html" %}
|
||||
<li class="md-tabs__item">
|
||||
{% set class = "md-tabs__link" %}
|
||||
{% if not page.ancestors | length and nav | selectattr("url", page.url) %}
|
||||
<a
|
||||
href="{{ nav_item.url | url }}"
|
||||
class="md-tabs__link md-tabs__link--active"
|
||||
>
|
||||
{{ nav_item.title }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ nav_item.url | url }}" class="md-tabs__link">
|
||||
{{ nav_item.title }}
|
||||
</a>
|
||||
{% set class = "md-tabs__link md-tabs__link--active" %}
|
||||
{% endif %}
|
||||
<a href="{{ nav_item.url | url }}" class="{{ class }}">
|
||||
{{ nav_item.title }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Main navigation item with nested items -->
|
||||
@ -49,21 +44,13 @@
|
||||
<!-- Render item -->
|
||||
{% else %}
|
||||
<li class="md-tabs__item">
|
||||
{% set class = "md-tabs__link" %}
|
||||
{% if nav_item.active %}
|
||||
<a
|
||||
href="{{ (nav_item.children | first).url | url }}"
|
||||
class="md-tabs__link md-tabs__link--active"
|
||||
>
|
||||
{{ title }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a
|
||||
href="{{ (nav_item.children | first).url | url }}"
|
||||
class="md-tabs__link"
|
||||
>
|
||||
{{ title }}
|
||||
</a>
|
||||
{% set class = "md-tabs__link md-tabs__link--active" %}
|
||||
{% endif %}
|
||||
<a href="{{ (nav_item.children | first).url | url }}" class="{{ class }}">
|
||||
{{ title }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user