mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
livereload: Maintain the scroll position if possible
This fixes #3824: when the current pathname is the same as the one to be loaded, just call location.reload() so that the current scroll position can be preserved, instead of assigning to location.href, which will cause the scroll position to be lost.
This commit is contained in:
parent
88e1bca92c
commit
7231d5a829
1 changed files with 6 additions and 1 deletions
|
@ -122,7 +122,12 @@ HugoReload.prototype.reload = function(path, options) {
|
|||
}
|
||||
|
||||
path = path.substring(prefix.length);
|
||||
window.location.href = path;
|
||||
|
||||
if (window.location.pathname === path) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
window.location.href = path;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue