Skip to content

Commit

Permalink
Re-instate disableLiveReload as a config option (and not just a flag)
Browse files Browse the repository at this point in the history
Closes #11259
  • Loading branch information
bep committed Jul 19, 2023
1 parent 2f11e67 commit f1a061e
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 14 deletions.
13 changes: 6 additions & 7 deletions commands/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions config/allconfig/allconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
20 changes: 20 additions & 0 deletions testscripts/commands/server_disablelivereload.txt
Original file line number Diff line number Diff line change
@@ -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>
21 changes: 21 additions & 0 deletions testscripts/commands/server_disablelivereload__config.txt
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit f1a061e

Please sign in to comment.