{% assign sidebar = site.data.sidebars[page.sidebar].entries %}
<ul id="mysidebar" class="nav">
  <li class="sidebarTitle">{{sidebar[0].product}} {{sidebar[0].version}}</li>
  {% for entry in sidebar %}
  {% for folder in entry.folders %}
  {% if folder.output == nil or folder.output contains "web"%}
  {% if folder.url != nil and page.url contains folder.url %}
  <li class = "active" >
  {% else %}
  <li>
  {% endif %}
      <a title="{{folder.title}}" href="{{folder.url | default:"#" }}">{{folder.title}}</a>
      <ul>
          {% for folderitem in folder.folderitems %}
          {% if folderitem.output == nil or folderitem.output contains "web" %}
          {% if folderitem.external_url %}
          <li><a title="{{folderitem.title}}" href="{{folderitem.external_url}}" target="_blank" rel="noopener">{{folderitem.title}}</a></li>
          {% elsif page.url contains folderitem.url %}
          <li class="active"><a title="{{folderitem.title}}" href="{{folderitem.url}}">{{folderitem.title}}</a></li>
          {% elsif folderitem.type == "empty" %}
          <li><a title="{{folderitem.title}}" href="{{folderitem.url}}">{{folderitem.title}}</a></li>

          {% else %}
          <li><a title="{{folderitem.title}}" href="{{folderitem.url}}">{{folderitem.title}}</a></li>
          {% endif %}
          {% for subfolders in folderitem.subfolders %}
          {% if subfolders.output == nil or subfolders.output contains "web" %}
          <li class="subfolders">
              <a title="{{subfolders.title}}" href="{{subfolders.url | default:"#" }}">{{ subfolders.title }}</a>
              <ul>
                  {% for subfolderitem in subfolders.subfolderitems %}
                  {% if subfolderitem.output == nil or subfolderitem.output contains "web" %}
                  {% if subfolderitem.external_url %}
                  <li><a title="{{subfolderitem.title}}" href="{{subfolderitem.external_url}}" target="_blank" rel="noopener">{{subfolderitem.title}}</a></li>
                  {% elsif page.url == subfolderitem.url %}
                  <li class="active"><a title="{{subfolderitem.title}}" href="{{subfolderitem.url}}">{{subfolderitem.title}}</a></li>
                  {% else %}
                  <li><a title="{{subfolderitem.title}}" href="{{subfolderitem.url }}">{{subfolderitem.title}}</a></li>
                  {% endif %}
                  {% endif %}
                  {% endfor %}
              </ul>
          </li>
          {% endif %}
          {% endfor %}
          {% endif %}
          {% endfor %}
      </ul>
   </li>
     {% endif %}
      {% endfor %}
      {% endfor %}
      <!-- if you aren't using the accordion, uncomment this block:
         <p class="external">
             <a href="#" id="collapseAll">Collapse All</a> | <a href="#" id="expandAll">Expand All</a>
         </p>
         -->
</ul>

<!--
This highlights the active parent class in the navgoco sidebar. This is
critical so that the parent expands when you're viewing a page. This must
appear below the sidebar code above. Otherwise, if placed inside
customscripts.js, the script runs before the sidebar code runs and the
class never gets inserted.
-->
<script>$("li.active").parents('li').addClass("active");</script>
