{% macro nav_list(items, class_name=none) %}
  {% for item in items %}
    {{ nav_entry(item, class_name) }}
  {% endfor %}
{% endmacro %}

{% macro nav_entry(items, class_name=none) %}
  <div class="global-sidebar-entry {{ class_name if class_name }}">
    {% if not caller %}
      {% for item in items %}
        {% if not item.disable %}
          {% if item.header %}
            {% if item.link %}
              {{ nav_item(
                  item.link,
                  item.text,
                  "clickable-header " ~ (item.class_name if item.class_name),
                  icon=item.icon
                )
              }}
            {% else %}
              {{ nav_header(item.text, item.class_name, item.icon) }}
            {% endif %}
          {% else %}
            {{ nav_item(
                item.link,
                item.text,
                item.class_name,
                item.is_external,
                item.color,
                item.icon
              )
            }}
          {% endif %}
        {% endif %}
      {% endfor %}
    {% else %}
      {{ caller() }}
    {% endif %}
  </div>
{% endmacro %}

{% macro nav_header(text, class_name=none, icon=none) %}
  <div class="global-sidebar-entry-item header {{ class_name if class_name }}">
    {% if icon %}
      <img src="{{ icon }}" class="global-sidebar-entry-item-icon" />
    {% endif %}
    {% if not caller %}
      {{ text }}
    {% else %}
      {{ caller() }}
    {% endif %}
  </div>
{% endmacro %}

{% macro nav_item(link, text=link, class_name=none, is_external=false, color=none, icon=none) %}
  <a
  class="global-sidebar-entry-item {{ class_name if class_name }}"
  {% if color %}
    style="color: {{ color }}"
  {% endif %}
  href="{{ link }}"
  {% if is_external %}
  target="_blank"
  {% endif %}
  > {% if icon %}
      <img src="{{ icon }}" class="global-sidebar-entry-item-icon" />
    {% endif %}
    {% if not caller %}
      {{ text }}
    {% else %}
      {{ caller() }}
    {% endif %}
  </a>
{% endmacro %}
