<div class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">

        <!-- Collapsed navigation -->
        <div class="navbar-header{% if nav.homepage.active %} active{% endif %}">
            <!-- Main title -->
            <a class="navbar-brand" href="{{ nav.homepage.url|url }}">
                <img src='{{ "/img/logo.svg"|url }}' width="32" />
                <span>{{ config.site_name }}</span>
                <!--span style="font-size: 0.7em;">{{ config.extra.version }}</span-->
            </a>

            {%- if nav|length>1 or (page and (page.next_page or page.previous_page)) or config.repo_url %}
            <!-- Expander button -->
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            {% endif %}
        </div>

        <!-- Expanded navigation -->
        <div class="navbar-collapse collapse">
            {%- block site_nav %}
            {%- if nav|length>1 %}
                <!-- Main navigation -->
                <ul class="nav navbar-nav">
                {% for nav_item in nav %}
                {% if nav_item.children %}
                    <li class="dropdown{% if nav_item.active %} active{% endif %}">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ nav_item.title }} <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                        {% for nav_item in nav_item.children %}
                            {% if "mastodon" in nav_item.title.lower() %}
                                <li {% if nav_item.active %}class="active"{% endif %}>
                                    <a href="{{ nav_item.url|url }}" rel="me">{{ nav_item.title }}</a>
                                </li>
                            {% else %}
                                {% include "nav-sub.html" %}
                            {% endif %}
                        {% endfor %}
                        </ul>
                    </li>
                {% elif not nav_item.is_page or not nav_item.meta.no_nav %}
                    <li {% if nav_item.active %}class="active"{% endif %}>
                        <a href="{{ nav_item.url|url }}">
                        {%- if nav_item.is_page and nav_item.meta.nav_icon -%}
                            <i class="{{ nav_item.meta.nav_icon }}"></i>
                        {%- endif %} {{ nav_item.title }}</a>
                    </li>
                {% endif %}
                {% endfor %}
                </ul>
            {%- endif %}
            {%- endblock %}

            <ul class="nav navbar-nav navbar-right">
                {%- block search_button %}
                    {%- if 'search' in config['plugins'] %}
                    <li>
                        <a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
                            <i class="fas fa-search"></i> Search
                        </a>
                    </li>
                    {%- endif %}
                {%- endblock %}

                {%- block next_prev %}
                    {%- if page and (page.next_page or page.previous_page) %}
                    <li {% if not page.previous_page %}class="disabled"{% endif %}>
                        <a rel="prev" {% if page.previous_page %}href="{{ page.previous_page.url|url }}"{% endif %}>
                            <i class="fas fa-arrow-left"></i> Previous
                        </a>
                    </li>
                    <li {% if not page.next_page %}class="disabled"{% endif %}>
                        <a rel="next" {% if page.next_page %}href="{{ page.next_page.url|url }}"{% endif %}>
                            Next <i class="fas fa-arrow-right"></i>
                        </a>
                    </li>
                    {%- endif %}
                {%- endblock %}

                {%- block repo %}
                    {%- if config.repo_url and 0 %}
                        <li>
                        <a href="{{ config.repo_url }}">
                            {%- if config.repo_name == 'GitHub' -%}
                            <i class="fab fa-github"></i> {{ config.repo_name }}
                            {%- elif config.repo_name == 'Bitbucket' -%}
                            <i class="fab fa-bitbucket"></i> {{ config.repo_name }}
                            {%- elif config.repo_name == 'GitLab' -%}
                            <i class="fab fa-gitlab"></i> {{ config.repo_name }}
                            {%- else -%}
                            {{ config.repo_name }}
                            {%- endif -%}
                        </a>
                        </li>
                    {%- endif %}
                {%- endblock %}
            </ul>
        </div>
    </div>
</div>
