mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-02 08:30:07 +03:00
Rename interface contentRewriter to contentTransformer
Is is a much better name.
This commit is contained in:
parent
efb564775a
commit
66cf3bdc77
5 changed files with 26 additions and 26 deletions
|
@ -5,19 +5,19 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func LiveReloadInject(rw contentRewriter) {
|
||||
func LiveReloadInject(ct contentTransformer) {
|
||||
match := []byte("</body>")
|
||||
port := viper.GetString("port")
|
||||
replace := []byte(`<script>document.write('<script src="http://'
|
||||
+ (location.host || 'localhost').split(':')[0]
|
||||
+ ':` + port + `/livereload.js?mindelay=10"></'
|
||||
+ 'script>')</script></body>`)
|
||||
newcontent := bytes.Replace(rw.Content(), match, replace, -1)
|
||||
newcontent := bytes.Replace(ct.Content(), match, replace, -1)
|
||||
|
||||
if len(newcontent) == len(rw.Content()) {
|
||||
if len(newcontent) == len(ct.Content()) {
|
||||
match := []byte("</BODY>")
|
||||
newcontent = bytes.Replace(rw.Content(), match, replace, -1)
|
||||
newcontent = bytes.Replace(ct.Content(), match, replace, -1)
|
||||
}
|
||||
|
||||
rw.Write(newcontent)
|
||||
ct.Write(newcontent)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue