{{ $currentPage := . }}
{{ $currentVersion := (index (findRE "[^/]+.*?" .RelPermalink) 0) }}
<aside class="sidebar">
  <div class="sidebar-toggle" onclick="toggle_sidebar('sidebar-closed');return false;"><a href="#">&#59672;</a></div>
  <div class="search-and-nav-toggle">
    <div class="sidebar--search">
      <input  class="sidebar--search-field"
              id="algolia-search-input"
              type="text"
              accesskey="s"
              autocomplete="off"
              autocorrect="off"
              autocapitalize="off"
              spellcheck="false"
              dir="auto"
              placeholder="Search {{ $currentVersion }}">
    </div>
    <a id="contents-toggle-btn" href="#">
      <span class="toggle-hamburger"></span>
    </a>
  </div>
  <ul id="nav-tree">

  {{ $mainMenu := (index .Site.Menus (replaceRE "[.]" "_" $currentVersion)) }}
  {{ $cloudMenu := (index .Site.Menus (print (replaceRE "[.]" "_" $currentVersion) "_cloud")) }}
  {{ $refMenu := (index .Site.Menus (print (replaceRE "[.]" "_" $currentVersion) "_ref")) }}

  <!-- Main Section -->
  {{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $mainMenu) }}

  <!-- Cloud Section -->
  <h4 class="reference">{{ .Site.Data.products.cloud.shortname }}</h4>
  {{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $cloudMenu) }}

  <!-- Reference Section -->
  <h4 class="reference">Reference</h4>
  {{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $refMenu) }}

  </ul>
</aside>
