Fix rendering of empty pane in mobile navigation when no headlines are given

This commit is contained in:
squidfunk 2016-12-30 21:11:05 +01:00
parent d7ba0134a0
commit ca0de52b45
2 changed files with 26 additions and 8 deletions

View File

@ -24,14 +24,22 @@
</li> </li>
{% elif nav_item == page %} {% elif nav_item == page %}
<li class="md-nav__item"> <li class="md-nav__item">
{% set toc = page.toc %}
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc"> <input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
{% if "\x3ch1 id=" in page.content %}
{% set toc = (toc | first).children %}
{% endif %}
{% if toc and (toc | first) %}
<label class="md-nav__link md-nav__link--active" for="toc"> <label class="md-nav__link md-nav__link--active" for="toc">
{{ nav_item.title }} {{ nav_item.title }}
</label> </label>
{% endif %}
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-nav__link md-nav__link--active"> <a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-nav__link md-nav__link--active">
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
{% if page.toc %}
{% include "partials/toc.html" %} {% include "partials/toc.html" %}
{% endif %}
</li> </li>
{% else %} {% else %}
<li class="md-nav__item"> <li class="md-nav__item">

View File

@ -57,22 +57,32 @@
<!-- Main navigation item with nested items --> <!-- Main navigation item with nested items -->
{% elif nav_item == page %} {% elif nav_item == page %}
<li class="md-nav__item"> <li class="md-nav__item">
{% set toc = page.toc %}
<!-- Active checkbox expands items contained within nested section --> <!-- Active checkbox expands items contained within nested section -->
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" <input class="md-toggle md-nav__toggle" data-md-toggle="toc"
type="checkbox" id="toc" /> type="checkbox" id="toc" />
<!-- Nasty hack - see partials/toc.html for more information -->
{% if "\x3ch1 id=" in page.content %}
{% set toc = (toc | first).children %}
{% endif %}
<!-- Expand active pages --> <!-- Expand active pages -->
{% if toc and (toc | first) %}
<label class="md-nav__link md-nav__link--active" for="toc"> <label class="md-nav__link md-nav__link--active" for="toc">
{{ nav_item.title }} {{ nav_item.title }}
</label> </label>
{% endif %}
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" <a href="{{ nav_item.url }}" title="{{ nav_item.title }}"
class="md-nav__link md-nav__link--active"> class="md-nav__link md-nav__link--active">
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
<!-- Show table of contents --> <!-- Show table of contents -->
{% if page.toc %}
{% include "partials/toc.html" %} {% include "partials/toc.html" %}
{% endif %}
</li> </li>
<!-- Main navigation item --> <!-- Main navigation item -->