{# API #}
{%- set props = props | default([]) -%}
{%- set _elementType = props.elementType | default('nav') -%}
{%- set _goBackTitle = props.goBackTitle | default('') -%}
{%- set _items = props.items | default([]) -%}

{# Class names #}
{%- set _rootClassName = _spiritClassPrefix ~ 'Breadcrumbs' -%}

{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _styleProps.className ] -%}

<{{ _elementType }} {{ mainProps(props) }} {{ styleProp(_styleProps) }} {{ classProp(_classNames) }} aria-label="Breadcrumb">
{% apply spaceless %}
    {%- if _items|length > 0 -%}
        <ol>
            {% for item in _items %}
                {% if loop.index is same as(_items|length - 1) and _goBackTitle is not same as('') %}
                    <BreadcrumbsItem href="{{ item.url ?? null }}" isGoBackOnly>{{ _goBackTitle }}</BreadcrumbsItem>
                {% endif %}
                <BreadcrumbsItem isCurrent={ loop.last } href={ item.url ?? null }>{{ item.title }}</BreadcrumbsItem>
            {% endfor %}
        </ol>
    {%- else -%}
        {%- block content -%}{%- endblock -%}
    {%- endif -%}
{% endapply %}
</{{ _elementType }}>
