Merge pull request #2675 from notriddle/sidebar/active-query

Break off query string when comparing url for sidebar
This commit is contained in:
Eric Huss 2025-04-22 13:48:42 +00:00 committed by GitHub
commit 12b4a9631a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -10,7 +10,7 @@ class MDBookSidebarScrollbox extends HTMLElement {
connectedCallback() {
this.innerHTML = '{{#toc}}{{/toc}}';
// Set the current, active page, and reveal it if it's hidden
let current_page = document.location.href.toString().split("#")[0];
let current_page = document.location.href.toString().split("#")[0].split("?")[0];
if (current_page.endsWith("/")) {
current_page += "index.html";
}

View file

@ -0,0 +1,17 @@
// This GUI test checks the active page sidebar highlight.
go-to: |DOC_PATH| + "index.html"
assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter")
go-to: |DOC_PATH| + "individual/index.html"
assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags")
go-to: |DOC_PATH| + "index.html?highlight=test"
assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter")
go-to: |DOC_PATH| + "individual/index.html?highlight=test"
assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags")