mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2025-07-16 11:41:27 +00:00
UX Improvements: Close TOC when navigating.
This commit is contained in:
parent
bbd7f33640
commit
01b52eaa95
18
assets/book-header.js
Normal file
18
assets/book-header.js
Normal file
@ -0,0 +1,18 @@
|
||||
(function () {
|
||||
let tocLinks = document.querySelectorAll("#TableOfContents li");
|
||||
let tocInput = document.getElementById("toc-control");
|
||||
tocLinks.forEach(l =>
|
||||
l.addEventListener("click",
|
||||
() => tocInput.checked = false));
|
||||
})();
|
||||
(function () {
|
||||
let menuLabel = document.querySelector("label[for='menu-control']");
|
||||
let menuInput = document.getElementById("menu-control");
|
||||
let tocInput = document.getElementById("toc-control");
|
||||
menuLabel.addEventListener("click",
|
||||
function () {
|
||||
if (!menuInput.checked) {
|
||||
tocInput.checked = false;
|
||||
}
|
||||
});
|
||||
})();
|
@ -21,6 +21,13 @@
|
||||
|
||||
{{ partial "docs/inject/content-before" . }}
|
||||
{{ template "main" . }} <!-- Page Content -->
|
||||
|
||||
<!-- Improve .book-header usability on mobile devices -->
|
||||
{{ $script := resources.Get "book-header.js" | resources.Minify }}
|
||||
{{ with $script.Content }}
|
||||
<script>{{ . | safeJS }}</script>
|
||||
{{ end }}
|
||||
|
||||
{{ partial "docs/inject/content-after" . }}
|
||||
|
||||
<footer class="book-footer">
|
||||
|
Loading…
Reference in New Issue
Block a user