Fixed empty table of contents being rendered

This commit is contained in:
squidfunk 2021-04-24 11:15:05 +02:00
parent 9296dc3bca
commit 319db2d57d
4 changed files with 10 additions and 10 deletions

View File

@ -40,10 +40,10 @@
{% set toc = page.toc %}
<input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc">
{% set first = toc | first %}
{% if first is defined and first.level == 1 %}
{% if first and first.level == 1 %}
{% set toc = first.children %}
{% endif %}
{% if toc is iterable %}
{% if toc %}
<label class="md-nav__link md-nav__link--active" for="__toc">
{{ nav_item.title }}
<span class="md-nav__icon md-icon"></span>
@ -52,7 +52,7 @@
<a href="{{ nav_item.url | url }}" class="md-nav__link md-nav__link--active">
{{ nav_item.title }}
</a>
{% if toc is iterable %}
{% if toc %}
{% include "partials/toc.html" %}
{% endif %}
</li>

View File

@ -5,10 +5,10 @@
<nav class="md-nav md-nav--secondary" aria-label="{{ lang.t('toc.title') }}">
{% set toc = page.toc %}
{% set first = toc | first %}
{% if first is defined and first.level == 1 %}
{% if first and first.level == 1 %}
{% set toc = first.children %}
{% endif %}
{% if toc is iterable %}
{% if toc %}
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
{{ lang.t("toc.title") }}

View File

@ -102,12 +102,12 @@
<!-- Hack: see partials/toc.html for more information -->
{% set first = toc | first %}
{% if first is defined and first.level == 1 %}
{% if first and first.level == 1 %}
{% set toc = first.children %}
{% endif %}
<!-- Render table of contents, if not empty -->
{% if toc is iterable %}
{% if toc %}
<label class="md-nav__link md-nav__link--active" for="__toc">
{{ nav_item.title }}
<span class="md-nav__icon md-icon"></span>
@ -121,7 +121,7 @@
</a>
<!-- Show table of contents -->
{% if toc is iterable %}
{% if toc %}
{% include "partials/toc.html" %}
{% endif %}
</li>

View File

@ -33,12 +33,12 @@
directly continue with the children of the anchor.
-->
{% set first = toc | first %}
{% if first is defined and first.level == 1 %}
{% if first and first.level == 1 %}
{% set toc = first.children %}
{% endif %}
<!-- Render item list -->
{% if toc is iterable %}
{% if toc %}
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
{{ lang.t("toc.title") }}