Fix nav scroll feature (#898)

The nav scroll feature had stopped working (altogether),
due to the change from absolute to relative urls.

This update uses the document location pathname as the `href`.
It appears to work locally.
This commit is contained in:
Peter Mosses 2022-08-03 07:31:17 +02:00 committed by GitHub
parent 528141d30c
commit 672c284b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -460,7 +460,7 @@ jtd.setTheme = function(theme) {
// Scroll site-nav to ensure the link to the current page is visible
function scrollNav() {
const href = document.location.href.split('#')[0].replace(/(.+?)\/+$/, "$1");
const href = document.location.pathname;
const siteNav = document.getElementById('site-nav');
const targetLink = siteNav.querySelector('a[href="' + href + '"], a[href="' + href + '/"]');
if(targetLink){