diff --git a/assets/js/sidebar-v2.js b/assets/js/sidebar-v2.js new file mode 100644 index 00000000..b90ce91d --- /dev/null +++ b/assets/js/sidebar-v2.js @@ -0,0 +1,17 @@ +document.addEventListener("DOMContentLoaded", function() { + function expandToCurrentPage() { + const currentPage = document.getElementById("current-page"); + if (currentPage) { + let parentLabel = currentPage.closest("li"); + while (parentLabel) { + let checkbox = parentLabel.querySelector(".toggle-checkbox"); + if (checkbox) { + checkbox.checked = true; + } + parentLabel = parentLabel.closest("ul").closest("li"); + } + } + } + + expandToCurrentPage(); +}) \ No newline at end of file diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 81262387..2ad39279 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -68,3 +68,7 @@ <!-- Load Product Selector javascript --> {{ $jsProductSelector := resources.Get "js/product-selector.js" | minify | fingerprint "sha512" }} <script src="{{ $jsProductSelector.RelPermalink }}" type="text/javascript" integrity="{{ $jsProductSelector.Data.Integrity }}"></script> + +<!-- Load Sidebar v2 javascript --> +{{ $jsSidebarV2 := resources.Get "js/sidebar-v2.js" | minify | fingerprint "sha512" }} +<script src="{{ $jsSidebarV2.RelPermalink }}" type="text/javascript" integrity="{{ $jsSidebarV2.Data.Integrity }}"></script> \ No newline at end of file diff --git a/layouts/partials/sidebar-list-pages.html b/layouts/partials/sidebar-list-pages.html index b221b252..cc158d51 100644 --- a/layouts/partials/sidebar-list-pages.html +++ b/layouts/partials/sidebar-list-pages.html @@ -15,7 +15,7 @@ {{ partial "sidebar-list-pages.html" (dict "context" . "currentUrl" $currentUrl) }} {{ else if eq .Kind "page" }} {{ if eq $currentUrl .Permalink }} - <span class="box current partial"></span> + <span class="box current partial" id="current-page"></span> {{ else }} <span class="box-link partial"></span> {{ end }} diff --git a/layouts/partials/sidebar-v2.html b/layouts/partials/sidebar-v2.html index 894e5442..bc4f3c9b 100644 --- a/layouts/partials/sidebar-v2.html +++ b/layouts/partials/sidebar-v2.html @@ -37,7 +37,7 @@ <ul> {{ range $products }} <li> - <a href="{{ .url }}" target="_blank">{{ .title }}</a> + <a href="{{ .url }}">{{ .title }}</a> </li> {{ end }} </ul>