summaryrefslogtreecommitdiffhomepage
path: root/livereload
diff options
context:
space:
mode:
authorYihui Xie <[email protected]>2017-08-22 10:29:09 -0500
committerBjørn Erik Pedersen <[email protected]>2017-08-22 20:26:33 +0200
commit7231d5a829f8d97336a2120afde1260db6ee6541 (patch)
treeb1ab5c8924175f39cfba5adf17cd7b523f5b3224 /livereload
parent88e1bca92c9df7e6c8b0bdf5a830a58e5ecd8e09 (diff)
downloadhugo-7231d5a829f8d97336a2120afde1260db6ee6541.tar.gz
hugo-7231d5a829f8d97336a2120afde1260db6ee6541.zip
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.
Diffstat (limited to 'livereload')
-rw-r--r--livereload/livereload.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/livereload/livereload.go b/livereload/livereload.go
index a5da891fc..74702175f 100644
--- a/livereload/livereload.go
+++ b/livereload/livereload.go
@@ -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;
};