<aside id="sidebar-left" class="sidebar-left">
    <div class="sidebar-header">
        <div class="sidebar-title">Modules</div>
        <div class="sidebar-toggle d-none d-md-block" data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
            <i class="fas fa-bars" aria-label="Toggle sidebar"></i>
        </div>
    </div>
    <div class="nano">
        <div class="nano-content">
            <nav id="menu" class="nav-main" role="navigation">
                <ul class="nav nav-main">
                    <li class="{% if sidebar_section == 'feeds' %}nav-active{% endif %}">
                        <a href="{% url 'cabinet:feeds:index' %}">
                            <i class="fas fa-rss-square" aria-hidden="true"></i>
                            <span>Feeds</span>
                        </a>
                    </li>
                    <li class="{% if sidebar_section == 'bots' %}nav-active{% endif %}">
                        <a href="{% url 'cabinet:bots:index' %}">
                            <i class="fas fa-robot" aria-hidden="true"></i>
                            <span>Telegram bots</span>
                        </a>
                    </li>
                </ul>
            </nav>

            {% if request.user.is_superuser %}
            <hr class="separator" />

            <div class="nav-subtitle">Admin</div>
            <nav class="nav-main" role="navigation">
                <ul class="nav nav-main">
                    <li class="nav-parent {% if sidebar_section|slice:':6' == 'admin_' %}nav-expanded nav-active{% endif %}">
                        <a href="#">
                            <i class="fas fa-cog" aria-hidden="true"></i>
                            <span>Configs</span>
                        </a>
                        <ul class="nav nav-children">
                            {% for slug, title in admin_configs.items %}
                            <li class="{% if sidebar_section == 'admin_'|add:slug %}nav-active{% endif %}">
                                <a href="{% url 'cabinet:admin_config' slug=slug %}" class="nav-link">{{ title }}</a>
                            </li>
                            {% endfor %}
                        </ul>
                    </li>
                </ul>
            </nav>
            {% endif %}
        </div>

        <script>
            // Maintain Scroll Position
            if (typeof localStorage !== 'undefined') {
                if (localStorage.getItem('sidebar-left-position') !== null) {
                    var initialPosition = localStorage.getItem('sidebar-left-position'),
                        sidebarLeft = document.querySelector('#sidebar-left .nano-content');

                    sidebarLeft.scrollTop = initialPosition;
                }
            }
        </script>
    </div>
</aside>
