<nav>
{{ partial "docs/search" . }}
{{ partial "docs/inject/menu-before" . }}

{{ if .Site.Params.BookMenuBundle }}
<div id="docstreeview">
    {{ partial "docs/menu-bundle" . }}
</div>
{{ else }}
    {{ partial "docs/menu-filetree" . }}
{{ end }}

{{ partial "docs/inject/menu-after" . }}
</nav>

<!-- Restore menu position as soon as possible to avoid flickering -->
<script>
(function() {
  var menu = document.querySelector("aside.book-menu nav");
  addEventListener("beforeunload", function(event) {
    localStorage.setItem("menu.scrollTop", menu.scrollTop);
  });
  menu.scrollTop = localStorage.getItem("menu.scrollTop");
})();
</script>
