{% macro nav(navigation) %}
            <nav class="col-md-2 d-none d-md-block bg-light sidebar">
                <div class="sidebar-sticky" id="sidebar_id">
                    <ul class="nav flex-column">
                        {% for category in navigation|sort %}
                        {% set items = navigation[category] %}
                        <h6 class="sidebar-heading justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
                            {{ category }}
                        </h6>
                        {% for item in items|sort(attribute='name') %}
                        <li class="nav-item">
                            {{ item | string }}
                        </li>
                        {% endfor %}
                        {% endfor %}
                        <script>
                            feather.replace();
                            var element = document.getElementById("sidebar_id");
                            var searchParams = new URLSearchParams(window.location.search);
                            if (searchParams.has('navpos')) {
                                var nav_pos = parseInt(searchParams.get('navpos'));
                                if (!isNaN(nav_pos))
                                    element.scrollTop = nav_pos;
                            }
                        </script>
                    </ul>
                </div>
            </nav>
{% endmacro %}
