hugo-book/layouts/partials/docs/menu.html
tyler71 e037b7c70f mobile toc menu (#121)
* Implement TOC for mobile
* Uses Page title as label
* Label entries so that tapping TOC will hide menu
* Switch to medium breakpoint
* Correct tos -> toc
* toc-menu-control -> toc-control
2020-01-13 17:44:24 +01:00

25 lines
658 B
HTML

<nav id="BookMenu">
{{ partial "docs/brand" . }}
{{ partial "docs/search" . }}
{{ partial "docs/inject/menu-before" . }}
{{ if .Site.Params.BookMenuBundle }}
{{ partial "docs/menu-bundle" . }}
{{ 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>