Merge pull request #3028 from bens-schreiber/schreiber/fix-pretty-urls

fix: pretty url toc highlighting
This commit is contained in:
Eric Huss 2026-05-19 21:51:01 +00:00 committed by GitHub
commit 4f5b48792f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,7 +23,8 @@ class MDBookSidebarScrollbox extends HTMLElement {
link.href = path_to_root + href; link.href = path_to_root + href;
} }
// The 'index' page is supposed to alias the first chapter in the book. // The 'index' page is supposed to alias the first chapter in the book.
if (link.href === current_page // Check both with and without the '.html' suffix to be robust against pretty URLs
if (link.href.replace(/\.html$/, '') === current_page.replace(/\.html$/, '')
|| i === 0 || i === 0
&& path_to_root === '' && path_to_root === ''
&& current_page.endsWith('/index.html')) { && current_page.endsWith('/index.html')) {