From f1a061e9ed6d9fffab5db9ae693e23ebe3b0cd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 19 Jul 2023 09:23:48 +0200 Subject: [PATCH] Re-instate disableLiveReload as a config option (and not just a flag) Closes #11259 --- commands/helpers.go | 13 ++++++------ config/allconfig/allconfig.go | 14 +++++++------ hugolib/site.go | 2 +- .../commands/server_disablelivereload.txt | 20 ++++++++++++++++++ .../server_disablelivereload__config.txt | 21 +++++++++++++++++++ 5 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 testscripts/commands/server_disablelivereload.txt create mode 100644 testscripts/commands/server_disablelivereload__config.txt diff --git a/commands/helpers.go b/commands/helpers.go index 5021221fb..d6c5e43ac 100644 --- a/commands/helpers.go +++ b/commands/helpers.go @@ -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 diff --git a/config/allconfig/allconfig.go b/config/allconfig/allconfig.go index a0d1d0ae8..9960c28f3 100644 --- a/config/allconfig/allconfig.go +++ b/config/allconfig/allconfig.go @@ -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. // {"identifiers": ["Content", "Unicode"] } EnableEmoji bool diff --git a/hugolib/site.go b/hugolib/site.go index eb6a4e344..b5c43fba3 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -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 index 000000000..6b1cd66cb --- /dev/null +++ b/testscripts/commands/server_disablelivereload.txt @@ -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 -- + + + + +Home. + + \ 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 index 000000000..fe49ff247 --- /dev/null +++ b/testscripts/commands/server_disablelivereload__config.txt @@ -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 -- + + + + +Home. + + \ No newline at end of file