{% comment %}
Embeds breadcrumb RDFa, follows ARIA guidelines. References:
- https://developers.google.com/search/docs/data-types/breadcrumb
- https://schema.org/BreadcrumbList
- https://www.w3.org/TR/wai-aria-practices/examples/breadcrumb/index.html
- https://search.google.com/structured-data/testing-tool
{% endcomment %}

{% assign url = page.url | regexReplace: '/index$|/index.html$|/$' -%}

{% if url.size > 0 -%}
<nav class="breadcrumbs" aria-label="breadcrumb">
  <ol class="breadcrumb-list" vocab="http://schema.org/" typeof="BreadcrumbList">
  {% assign breadcrumbs = page | breadcrumbsForPage -%} 
  {% if breadcrumbs -%}
  {% for crumb in breadcrumbs -%}
    <li class="breadcrumb-item {%- if forloop.last %} active {%- endif %}"
      property="itemListElement" typeof="ListItem"
      {%- if forloop.last %} aria-current="page"{% endif %}>
      {%- comment %}Avoid spaces here, it messes up formatting{% endcomment -%}
      <a href="{{ crumb.url | regexReplace: '/index$|/index.html$|/$' }}" property="item" typeof="WebPage">
        {%- comment %}Avoid spaces here, it messes up formatting{% endcomment -%}
        <span property="name">{{crumb.title}}</span>
      </a>
      <meta property="position" content="{{forloop.index0}}" />
      {%- if not forloop.last %}
      <span class="material-symbols child-icon" aria-hidden="true">chevron_right</span>
      {% endif %}
    </li>
  {% endfor %}
  {% endif -%}  
  </ol>
</nav>
{%- endif -%}
