{% macro articles(_articles, showLevels) %}
    {% for article in _articles %}
        {% set isFirst = loop.first %}
        {% if article.depth != 1 or (article.depth == 1 and page.level.startsWith(article.level) ) or isFirst %}
            {% set articleToString = article | dump %}
            <li class="chapter 
                {% if article.path == file.path and not article.anchor %}active{% endif %} {% if articleToString.indexOf('"'+file.path) > -1 %} selected {% endif %} {% if showLevels == false and article.depth != 1 %} hide {% endif %}"
                data-level="{{ article.level }}" 
                {% if article.path %}data-path="{{ article.path|resolveFile }}"{% endif %}>

                {% if article.path and getPageByPath(article.path) %}
                    <a href="{{ article.path|resolveFile }}{{ article.anchor }}" class="{% if article.depth == 1 %}hide{% endif %} ">
                {% elif article.url %}
                    <a target="_blank" href="{{ article.url }}">
                {% else %}
                    <span>
                {% endif %}
                        {% if article.level != "0" and config.pluginsConfig['theme-default'].showLevel %}
                            <b>{{ article.level }}.</b>
                        {% endif %}
                        {{ article.title }}
                {% if article.path  or article.url %}
                    </a>
                {% else %}
                    </span>
                {% endif %}

                {% if article.articles.length > 0 %}
                <ul class="articles">
                    {% if articleToString.indexOf('"'+file.path) > -1 and not config.pluginsConfig["theme-gestalt-yl "].doNotHideChildrenChapters %} {% set showLevels = true %} {% endif %}
                    {{ articles(article.articles, showLevels ) }}
                </ul>
                {% endif %}
            </li>
        {% endif %}
    {% endfor %}
{% endmacro %}

<ul class="summary">
    {% set _divider = false %}
    {% if config.links.sidebar  %}
    {% for linkTitle, link in config.links.sidebar  %}
        {% set _divider = true %}
        <li>
            <a href="{{ link }}" target="_blank" class="custom-link">{{ linkTitle }}</a>
        </li>
    {% endfor %}
    {% endif %}

    {% if _divider %}
    <li class="divider"></li>
    {% endif %}

    {% for part in summary.parts %}
        {% for article in parts.articles %}
            
        {% endfor %}
        {% if part.title %}
        {% set partToString = part | dump %}
        <li class="header {% if partToString.indexOf('"'+file.path) > -1 %} selected {% endif %}">{{ part.title }}</li>
        {% elif not loop.first %}
        <li class="divider"></li>
        {% endif %}
        {{ articles(part.articles, false) }}
    {% endfor %}
</ul>
