Skip to content

Commit 319db2d

Browse files
committed
Fixed empty table of contents being rendered
1 parent 9296dc3 commit 319db2d

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

material/partials/nav-item.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
{% set toc = page.toc %}
4141
<input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc">
4242
{% set first = toc | first %}
43-
{% if first is defined and first.level == 1 %}
43+
{% if first and first.level == 1 %}
4444
{% set toc = first.children %}
4545
{% endif %}
46-
{% if toc is iterable %}
46+
{% if toc %}
4747
<label class="md-nav__link md-nav__link--active" for="__toc">
4848
{{ nav_item.title }}
4949
<span class="md-nav__icon md-icon"></span>
@@ -52,7 +52,7 @@
5252
<a href="{{ nav_item.url | url }}" class="md-nav__link md-nav__link--active">
5353
{{ nav_item.title }}
5454
</a>
55-
{% if toc is iterable %}
55+
{% if toc %}
5656
{% include "partials/toc.html" %}
5757
{% endif %}
5858
</li>

material/partials/toc.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<nav class="md-nav md-nav--secondary" aria-label="{{ lang.t('toc.title') }}">
66
{% set toc = page.toc %}
77
{% set first = toc | first %}
8-
{% if first is defined and first.level == 1 %}
8+
{% if first and first.level == 1 %}
99
{% set toc = first.children %}
1010
{% endif %}
11-
{% if toc is iterable %}
11+
{% if toc %}
1212
<label class="md-nav__title" for="__toc">
1313
<span class="md-nav__icon md-icon"></span>
1414
{{ lang.t("toc.title") }}

src/partials/nav-item.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@
102102

103103
<!-- Hack: see partials/toc.html for more information -->
104104
{% set first = toc | first %}
105-
{% if first is defined and first.level == 1 %}
105+
{% if first and first.level == 1 %}
106106
{% set toc = first.children %}
107107
{% endif %}
108108

109109
<!-- Render table of contents, if not empty -->
110-
{% if toc is iterable %}
110+
{% if toc %}
111111
<label class="md-nav__link md-nav__link--active" for="__toc">
112112
{{ nav_item.title }}
113113
<span class="md-nav__icon md-icon"></span>
@@ -121,7 +121,7 @@
121121
</a>
122122

123123
<!-- Show table of contents -->
124-
{% if toc is iterable %}
124+
{% if toc %}
125125
{% include "partials/toc.html" %}
126126
{% endif %}
127127
</li>

src/partials/toc.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
directly continue with the children of the anchor.
3434
-->
3535
{% set first = toc | first %}
36-
{% if first is defined and first.level == 1 %}
36+
{% if first and first.level == 1 %}
3737
{% set toc = first.children %}
3838
{% endif %}
3939

4040
<!-- Render item list -->
41-
{% if toc is iterable %}
41+
{% if toc %}
4242
<label class="md-nav__title" for="__toc">
4343
<span class="md-nav__icon md-icon"></span>
4444
{{ lang.t("toc.title") }}

0 commit comments

Comments
 (0)