wiki-grav/plugins/page-toc/templates/components/page-toc.html.twig

27 lines
823 B
Twig
Raw Normal View History

{% macro toc_loop(items) %}
{% for item in items %}
{% set class = loop.first ? 'first' : loop.last ? 'last' : null %}
<li {% if class %}class="{{ class }}"{% endif %}>
<a href="{{ item.uri }}">{{ item.label | raw }}</a>
{% if item.children|length > 0 %}
<ul>
2023-08-03 16:57:09 +02:00
{{ _self.toc_loop(item.children) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% if active or toc_config_var('active') %}
<div class="page-toc">
{% set table_of_contents = toc_items(page.content) %}
{% if table_of_contents is not empty %}
<h4>{{ 'PLUGIN_PAGE_TOC.TABLE_OF_CONTENTS'|t }}</h4>
<ul>
2023-08-03 16:57:09 +02:00
{{ _self.toc_loop(table_of_contents.children) }}
</ul>
{% endif %}
</div>
{% endif %}