1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-27 17:00:54 +01:00

Fixed #5: Page without headlines renders empty list in table of contents

This commit is contained in:
squidfunk 2016-02-21 18:19:25 +01:00
parent ba72ddb949
commit 610d8c0e95
3 changed files with 39 additions and 48 deletions

View File

@ -2,6 +2,7 @@ mkdocs-material-0.x.x (2016-xx-xx)
* Fixed #3: Ordered lists within an unordered list have ::before content * Fixed #3: Ordered lists within an unordered list have ::before content
* Fixed #4: Click on Logo/Title without Github-Repository: "None" * Fixed #4: Click on Logo/Title without Github-Repository: "None"
* Fixed #5: Page without headlines renders empty list in table of contents
* Moved Modernizr to top to ensure basic usability in IE8 * Moved Modernizr to top to ensure basic usability in IE8
mkdocs-material-0.1.2 (2016-02-16) mkdocs-material-0.1.2 (2016-02-16)

View File

@ -13,25 +13,21 @@
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
{% if nav_item == current_page %} {% if nav_item == current_page %}
<ul> {% if h1 %}
{% for toc_item in toc %} {% set toc_item = toc | first %}
{% if h1 %} {% set toc = toc_item.children %}
{% for toc_item in toc_item.children %} {% endif %}
<li class="anchor"> {% if toc %}
<a title="{{ toc_item.title }}" href="{{ toc_item.url }}"> <ul>
{{ toc_item.title }} {% for toc_item in toc %}
</a> <li class="anchor">
</li> <a title="{{ toc_item.title }}" href="{{ toc_item.url }}">
{% endfor %} {{ toc_item.title }}
{% else %} </a>
<li class="anchor"> </li>
<a title="{{ toc_item.title }}" href="{{ toc_item.url }}"> {% endfor %}
{{ toc_item.title }} </ul>
</a> {% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %} {% endif %}
</li> </li>
{% endif %} {% endif %}

View File

@ -21,38 +21,32 @@
<!-- Expand active pages --> <!-- Expand active pages -->
{% if nav_item == current_page %} {% if nav_item == current_page %}
<ul>
<!-- Render anchors of active page --> <!--
{% for toc_item in toc %} The top-level anchor must be skipped if the article contains a h1
headline, since it would be redundant to the link to the current page
that is located just above the anchor. Therefore we directly continue
with the children of the anchor.
-->
{% if h1 %}
{% set toc_item = toc | first %}
{% set toc = toc_item.children %}
{% endif %}
<!-- <!-- Render anchors of active page -->
The top-level anchor must be skipped if the article contains a h1 {% if toc %}
headline, since it would be redundant to the link to the current <ul>
page that is located just above the anchor. Therefore we directly {% for toc_item in toc %}
continue with the children of the anchor.
-->
{% if h1 %}
{% for toc_item in toc_item.children %}
<!-- Render anchor --> <!-- Render anchor -->
<li class="anchor"> <li class="anchor">
<a title="{{ toc_item.title }}" href="{{ toc_item.url }}"> <a title="{{ toc_item.title }}" href="{{ toc_item.url }}">
{{ toc_item.title }} {{ toc_item.title }}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
{% else %} </ul>
{% endif %}
<!-- Render anchor -->
<li class="anchor">
<a title="{{ toc_item.title }}" href="{{ toc_item.url }}">
{{ toc_item.title }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %} {% endif %}
</li> </li>
{% endif %} {% endif %}