mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 22:50:35 +03:00
Load livereload.js from "/"
Fix #1406 Instead of loading the file from http://localhost:port/, it can be loaded from /.
This commit is contained in:
parent
0f438d1852
commit
ef4dfcec6c
2 changed files with 22 additions and 7 deletions
|
@ -2,18 +2,13 @@ package transform
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func LiveReloadInject(ct contentTransformer) {
|
||||
match := []byte("</body>")
|
||||
port := viper.GetString("port")
|
||||
replace := []byte(`<script data-no-instant>document.write('<script src="http://'
|
||||
+ (location.host || 'localhost').split(':')[0]
|
||||
+ ':` + port + `/livereload.js?mindelay=10"></'
|
||||
+ 'script>')</script></body>`)
|
||||
newcontent := bytes.Replace(ct.Content(), match, replace, -1)
|
||||
replace := []byte(`<script data-no-instant>document.write('<script src="/livereload.js?mindelay=10"></' + 'script>')</script></body>`)
|
||||
|
||||
newcontent := bytes.Replace(ct.Content(), match, replace, -1)
|
||||
if len(newcontent) == len(ct.Content()) {
|
||||
match := []byte("</BODY>")
|
||||
newcontent = bytes.Replace(ct.Content(), match, replace, -1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue