{% assign item = include.item_data %}

{% assign equality_check_depth = include.select_by_path_depth | default: 1 | plus: 1 %} {% assign url_components = page.url | split: '/' %} {% assign num_url_components = url_components | size %} {% assign first_component_of_current_url = url_components | slice: 0, equality_check_depth | join: '/' | append: '/' %} {% assign first_component_of_link_url = item.url | split: '/' | slice: 0, equality_check_depth | join: '/' | append: '/' %}

{% if num_url_components >= equality_check_depth and first_component_of_current_url == first_component_of_link_url %}

{% assign active = true %}

{% else %}

{% assign active = false %}

{% endif %}

{% if include.can_select_active == true or active == false %}

{% assign linkable = true %}

{% else %}

{% assign linkable = false %}

{% endif %}

{% assign num_subitems = item.items | size %} {% if num_subitems > 0 and include.nested_nav_include %}

{% assign shows_subitems = true %}

{% else %}

{% assign shows_subitems = false %}

{% endif %}

{% if item %}

<li
  class="
    nav-item-{{ include.item_id }}
    {% if item.html_class %}{{ item.html_class }}{% endif %}
    {% unless item.url or shows_subitems %}item-missing-page{% endunless %}
    {% if active %}selected{% endif %}
    {% if item.url %}with-url{% endif %}
    {% if item.icon %}with-icon{% endif %}"
{% if item.description %}
  title="{{ item.description }}"
{% endif %}>

  {% if item.url and linkable %}
    <a class="title" href="{{ item.url }}">
  {% else %}
    <span class="title">
  {% endif %}

  {%- if item.icon -%}
    <i class="fas fa-{{ item.icon }} icon"></i>
  {%- endif -%}
  {{- item.title -}}

  {% if item.url and linkable %}
    </a><!-- .title -->
  {% else %}
    </span><!-- .title -->
  {% endif %}

  {% if include.show_detail %}
    {% if item.detail.include %}
      <div class="detail detail-include">
        {% include {{ item.detail.include }} %}
      </div>
    {% elsif item.detail.text %}
      <div class="detail detail-text">
        {{ item.detail.text | asciidocify }}
      </div>
    {% endif %}
  {% endif %}

  {% if shows_subitems %}
    {% include {{ include.nested_nav_include }} show_detail=include.show_detail item_data=include.item_data items=item.items %}
  {% endif %}

</li>

{% endif %}