mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 06:17:45 +00:00
Only do one livereload replacement
This commit is contained in:
1 parent
dd1db334ac
commit
08b582e187
1 file changed
+2
-2
@@ -24,12 +24,12 @@ func LiveReloadInject(ct contentTransformer) {
|
|||||||
replaceTemplate := `<script data-no-instant>document.write('<script src="/livereload.js?mindelay=10"></' + 'script>')</script>%s`
|
replaceTemplate := `<script data-no-instant>document.write('<script src="/livereload.js?mindelay=10"></' + 'script>')</script>%s`
|
||||||
replace := []byte(fmt.Sprintf(replaceTemplate, endBodyTag))
|
replace := []byte(fmt.Sprintf(replaceTemplate, endBodyTag))
|
||||||
|
|
||||||
newcontent := bytes.Replace(ct.Content(), match, replace, -1)
|
newcontent := bytes.Replace(ct.Content(), match, replace, 1)
|
||||||
if len(newcontent) == len(ct.Content()) {
|
if len(newcontent) == len(ct.Content()) {
|
||||||
endBodyTag = "</BODY>"
|
endBodyTag = "</BODY>"
|
||||||
replace := []byte(fmt.Sprintf(replaceTemplate, endBodyTag))
|
replace := []byte(fmt.Sprintf(replaceTemplate, endBodyTag))
|
||||||
match := []byte(endBodyTag)
|
match := []byte(endBodyTag)
|
||||||
newcontent = bytes.Replace(ct.Content(), match, replace, -1)
|
newcontent = bytes.Replace(ct.Content(), match, replace, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
ct.Write(newcontent)
|
ct.Write(newcontent)
|
||||||
|
|||||||
Reference in new issue
Block a user