Fixed table of contents breaking when class is set on h1

This commit is contained in:
squidfunk
2021-04-15 21:21:33 +02:00
parent f9f8c3afdb
commit 8d752312aa
6 changed files with 21 additions and 14 deletions

View File

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

View File

@@ -32,12 +32,13 @@
to the current page that is located just above the anchor. Therefore we
directly continue with the children of the anchor.
-->
{% if toc | first is defined and "\x3ch1 id=" in page.content %}
{% set toc = (toc | first).children %}
{% set first = toc | first %}
{% if first is defined and first.level == 1 %}
{% set toc = first.children %}
{% endif %}
<!-- Render item list -->
{% if toc | first is defined %}
{% if toc is iterable %}
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
{{ lang.t("toc.title") }}