<div class="sidebar p-2" x-show="sidebar_open" x-transition>
    <aside class="menu">
        {% for part in project.children %}
        {% if part.children and current_path[1] == part.id %}
        <ul class="menu-list">
            {% for chapter in part.children %}
            {% if mode == "draft" or not chapter.content.metadata.draft %}
            <li>
                <a href="{{ config.url_prefix }}/{{ part.id }}/{{ chapter.id }}{% if chapter.type == 'Section' %}/index{% endif %}.html">{{ loop.index }}. {{
                    chapter.content.metadata.title }}</a>
                <ul class="menu-list">

                    {% if chapter.children %}
                    {% for doc in chapter.children %}
                    {% if mode == "draft" or not doc.content.metadata.draft %}
                    <li>
                        <a
                                href="{{ config.url_prefix }}/{{ part.id }}/{{ chapter.id }}/{{ doc.id }}.html"
                                class="{% if doc.id == current_doc %}is-active{% endif %}"
                        >{{ loop.index }}. {{ doc.content.metadata.title | safe }}</a
                        >
                    </li>
                    {% endif %}
                    {% endfor %}
                    {% endif %}
                    {% endif %}
                </ul>
            </li>

            {% endfor %}
        </ul>
        {% endif %} {% endfor %}
    </aside>
</div>
