]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Re-instate disableLiveReload as a config option (and not just a flag)
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 19 Jul 2023 07:23:48 +0000 (09:23 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 19 Jul 2023 17:50:37 +0000 (19:50 +0200)
Closes #11259

commands/helpers.go
config/allconfig/allconfig.go
hugolib/site.go
testscripts/commands/server_disablelivereload.txt [new file with mode: 0644]
testscripts/commands/server_disablelivereload__config.txt [new file with mode: 0644]

index 5021221fb0009c76cf4f1aa50d540065b9a4695a..d6c5e43aced2c43c7c5314254e0f18629ec1c25a 100644 (file)
@@ -86,13 +86,12 @@ func flagsToCfgWithAdditionalConfigBase(cd *simplecobra.Commandeer, cfg config.P
 
        // Flags that we for some reason don't want to expose in the site config.
        internalKeySet := map[string]bool{
-               "quiet":             true,
-               "verbose":           true,
-               "watch":             true,
-               "disableLiveReload": true,
-               "liveReloadPort":    true,
-               "renderToMemory":    true,
-               "clock":             true,
+               "quiet":          true,
+               "verbose":        true,
+               "watch":          true,
+               "liveReloadPort": true,
+               "renderToMemory": true,
+               "clock":          true,
        }
 
        cmd := cd.CobraCommand
index a0d1d0ae8e69fe7cbc7bafb9f0fb5733a3aad949..9960c28f372d1ee07e4c32ad091a07d64bf4da03 100644 (file)
@@ -57,12 +57,11 @@ type InternalConfig struct {
        // Server mode?
        Running bool
 
-       Quiet             bool
-       Verbose           bool
-       Clock             string
-       Watch             bool
-       DisableLiveReload bool
-       LiveReloadPort    int
+       Quiet          bool
+       Verbose        bool
+       Clock          string
+       Watch          bool
+       LiveReloadPort int
 }
 
 // All non-params config keys for language.
@@ -454,6 +453,9 @@ type RootConfig struct {
        // Disable the injection of the Hugo generator tag on the home page.
        DisableHugoGeneratorInject bool
 
+       // Disable live reloading in server mode.
+       DisableLiveReload bool
+
        // Enable replacement in Pages' Content of Emoji shortcodes with their equivalent Unicode characters.
        // <docsmeta>{"identifiers": ["Content", "Unicode"] }</docsmeta>
        EnableEmoji bool
index eb6a4e344bb033285f1a8b926be394e5ec3c54c0..b5c43fba3c216cd138d8503119f2d9948dde69a5 100644 (file)
@@ -1058,7 +1058,7 @@ func (s *Site) renderAndWritePage(statCounter *uint64, name string, targetPath s
                        pd.AbsURLPath = s.absURLPath(targetPath)
                }
 
-               if s.watching() && s.conf.Internal.Running && !s.conf.Internal.DisableLiveReload {
+               if s.watching() && s.conf.Internal.Running && !s.conf.DisableLiveReload {
                        pd.LiveReloadBaseURL = s.Conf.BaseURLLiveReload().URL()
                }
 
diff --git a/testscripts/commands/server_disablelivereload.txt b/testscripts/commands/server_disablelivereload.txt
new file mode 100644 (file)
index 0000000..6b1cd66
--- /dev/null
@@ -0,0 +1,20 @@
+hugo server --renderToDisk --disableLiveReload &
+
+waitServer
+
+! grep 'livereload' public/index.html
+
+stopServer
+! stderr .
+
+-- hugo.toml --
+baseURL = "http://example.org/"
+disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
+-- layouts/index.html --
+<html>
+<head>
+</head>
+<body>
+Home.
+</body>
+</html>
\ No newline at end of file
diff --git a/testscripts/commands/server_disablelivereload__config.txt b/testscripts/commands/server_disablelivereload__config.txt
new file mode 100644 (file)
index 0000000..fe49ff2
--- /dev/null
@@ -0,0 +1,21 @@
+hugo server --renderToDisk &
+
+waitServer
+
+! grep 'livereload' public/index.html
+
+stopServer
+! stderr .
+
+-- hugo.toml --
+baseURL = "http://example.org/"
+disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
+disableLiveReload = true
+-- layouts/index.html --
+<html>
+<head>
+</head>
+<body>
+Home.
+</body>
+</html>
\ No newline at end of file