{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_breadcrumb') }}
{{ attach_library('ui_patterns/bs_breadcrumb.bs_breadcrumb_lib') }}

{# VARIABLES #}
{% set chevron = global_icon_right|default('fas fa-chevron-right') %}
{% set devider = separator|default("|") %}
{% if separator == 'slash' %}{% set devider = "/" %}{% endif %}
{% if separator == 'pipe' %}{% set devider = "|" %}{% endif %}
{% if separator == 'arrow' %}{% set devider = "&gt;" %}{% endif %}
{% if separator == 'raquo' %}{% set devider = "&raquo;" %}{% endif %}
{% if separator == 'icon' %}{% set devider = "<i class='fal fa-angle-right'></i>" %}{% endif %}
{% if separator == 'angle' %}{% set devider = "<i class='fal fa-angle-right'></i>" %}{% endif %}
{% if separator == 'chevron' %}{% set devider = "<i class='" ~ chevron ~ "'></i>" %}{% endif %}

{# TEMPLATE #}
{% if breadcrumb %}
  <nav aria-label="breadcrumb" class="{{ utility_classes|join(' ') }}">
    <ol class="breadcrumb mb-1">
      {%- for item in breadcrumb %}
        <li class="breadcrumb-item {{ not item.url ? 'active' }}">
          {% if item.url %}
            <a class="bci-text" href="{{ item.url }}">{{ item.text }}</a>{% if not loop.last %}{{ devider|raw }}{% endif %}
          {% else %}
            <span class="bci-text">{{ item.text }}</span>{% if not loop.last %}{{ devider|raw }}{% endif %}
          {% endif %}
        </li>
      {%- endfor %}
    </ol>
  </nav>
{% endif %}
