<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<div class="toc">
{% assign path =  page.path | remove: "/index.adoc" | remove_first: "_" | remove_first:  page.collection | remove_first: "/"  %}

{% assign current_guide = path | split: "/" | first %}
{% assign section = path | remove: current_guide | remove : "/" %}


{% if current_guide != nil %}

    {% assign current_guide_url = current_guide | prepend: "/" %} 


    {% assign guide = site.data.toc | where: "url", current_guide_url | first %} 


    {% if section != "" %}
       {% assign section_url = "/" | append: current_guide | append: "/" | append: section %}
       {% assign sect = guide.items | where: "url", section_url | first %}

       {% include section-toc.html section=sect title=false %}   
    {% else %}
        <ul>
            {% for sect in guide.items %}
               <li>
                   {% include section-toc.html section=sect title=true%}   
               </li>
            {% endfor %}
        </ul> 
    {% endif %}
{% else %}  
    {% for guide in site.data.toc %}

        <h2> 
<a href="{{site.attrs.base_url}}{{guide.url}}" class=''>{{guide.title}}</a> </h2>
        {% if guide.items %}
        <ul>
          {% for sect in guide.items %}
              <li>
                  {% include section-toc.html section=sect title=true%}   
              </li>
          {% endfor %}
        </ul>
        {% endif %}
    {% endfor %}
{% endif %}
</div>
