aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorspf13 <[email protected]>2014-05-28 19:01:24 -0400
committerspf13 <[email protected]>2014-05-28 19:01:24 -0400
commit7a8b754cada398241fc2d58d63ce58551f6c734c (patch)
treedb8d844f25cb462db3202b8b53d8433bde6bb4b7 /transform
parent4076d77029e0705f9e9aa43a347b033dbc2d3cc9 (diff)
downloadhugo-7a8b754cada398241fc2d58d63ce58551f6c734c.tar.gz
hugo-7a8b754cada398241fc2d58d63ce58551f6c734c.zip
Fixed #301. LiveReload works on any port now.
Diffstat (limited to 'transform')
-rw-r--r--transform/livereloadinject.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/transform/livereloadinject.go b/transform/livereloadinject.go
index a84f850ad..0973841b3 100644
--- a/transform/livereloadinject.go
+++ b/transform/livereloadinject.go
@@ -1,12 +1,17 @@
package transform
-import "bytes"
+import (
+ "bytes"
+
+ "github.com/spf13/viper"
+)
func LiveReloadInject(content []byte) []byte {
match := []byte("</body>")
+ port := viper.GetString("port")
replace := []byte(`<script>document.write('<script src="http://'
+ (location.host || 'localhost').split(':')[0]
- + ':1313/livereload.js?mindelay=10"></'
+ + ':` + port + `/livereload.js?mindelay=10"></'
+ 'script>')</script></body>`)
newcontent := bytes.Replace(content, match, replace, -1)