Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #301. LiveReload works on any port now.

  • Loading branch information...
commit 7a8b754cada398241fc2d58d63ce58551f6c734c 1 parent 4076d77
@spf13 authored
Showing with 9 additions and 2 deletions.
  1. +2 −0  commands/server.go
  2. +7 −2 transform/livereloadinject.go
View
2  commands/server.go
@@ -83,6 +83,8 @@ func server(cmd *cobra.Command, args []string) {
serverPort = sp.Port
}
+ viper.Set("port", serverPort)
+
if serverAppend {
viper.Set("BaseUrl", strings.TrimSuffix(BaseUrl, "/")+":"+strconv.Itoa(serverPort))
} else {
View
9 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)
Please sign in to comment.
Something went wrong with that request. Please try again.