mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Fix regression with site.IsServer when not running a server
Fixes #11006
This commit is contained in:
parent
99407c39ba
commit
9a235d0afc
10 changed files with 13 additions and 10 deletions
|
@ -339,7 +339,7 @@ func (r *rootCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args
|
||||||
|
|
||||||
b := newHugoBuilder(r, nil)
|
b := newHugoBuilder(r, nil)
|
||||||
|
|
||||||
if err := b.loadConfig(cd, true); err != nil {
|
if err := b.loadConfig(cd, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, net.Listener, string
|
||||||
listener := f.c.serverPorts[i].ln
|
listener := f.c.serverPorts[i].ln
|
||||||
logger := f.c.r.logger
|
logger := f.c.r.logger
|
||||||
|
|
||||||
r.Printf("Environment: %q", f.c.hugoTry().Deps.Site.Hugo().Environment)
|
r.Printf("Environment: %q\n", f.c.hugoTry().Deps.Site.Hugo().Environment)
|
||||||
|
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
if f.c.renderToDisk {
|
if f.c.renderToDisk {
|
||||||
|
|
|
@ -185,7 +185,7 @@ func (h *HugoSites) initRebuild(config *BuildCfg) error {
|
||||||
return errors.New("rebuild does not support 'ResetState'")
|
return errors.New("rebuild does not support 'ResetState'")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !h.Configs.Base.Internal.Running {
|
if !h.Configs.Base.Internal.Watch {
|
||||||
return errors.New("rebuild called when not in watch mode")
|
return errors.New("rebuild called when not in watch mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -327,6 +327,7 @@ func (s *IntegrationTestBuilder) initBuilder() error {
|
||||||
if s.Cfg.Running {
|
if s.Cfg.Running {
|
||||||
flags.Set("internal", maps.Params{
|
flags.Set("internal", maps.Params{
|
||||||
"running": s.Cfg.Running,
|
"running": s.Cfg.Running,
|
||||||
|
"watch": s.Cfg.Running,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -583,7 +583,7 @@ var defaultRenderStringOpts = renderStringOpts{
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageState) addDependency(dep identity.Provider) {
|
func (p *pageState) addDependency(dep identity.Provider) {
|
||||||
if !p.s.running() || p.pageOutput.cp == nil {
|
if !p.s.watching() || p.pageOutput.cp == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.pageOutput.cp.dependencyTracker.Add(dep)
|
p.pageOutput.cp.dependencyTracker.Add(dep)
|
||||||
|
|
|
@ -76,7 +76,7 @@ func newPageContentOutput(p *pageState, po *pageOutput) (*pageContentOutput, err
|
||||||
parent := p.init
|
parent := p.init
|
||||||
|
|
||||||
var dependencyTracker identity.Manager
|
var dependencyTracker identity.Manager
|
||||||
if p.s.running() {
|
if p.s.watching() {
|
||||||
dependencyTracker = identity.NewManager(pageContentOutputDependenciesID)
|
dependencyTracker = identity.NewManager(pageContentOutputDependenciesID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -389,8 +389,8 @@ func (s *siteRefLinker) refLink(ref string, source any, relative bool, outputFor
|
||||||
return link, nil
|
return link, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) running() bool {
|
func (s *Site) watching() bool {
|
||||||
return s.h != nil && s.h.Configs.Base.Internal.Running
|
return s.h != nil && s.h.Configs.Base.Internal.Watch
|
||||||
}
|
}
|
||||||
|
|
||||||
type whatChanged struct {
|
type whatChanged struct {
|
||||||
|
@ -1064,7 +1064,7 @@ func (s *Site) renderAndWritePage(statCounter *uint64, name string, targetPath s
|
||||||
pd.AbsURLPath = s.absURLPath(targetPath)
|
pd.AbsURLPath = s.absURLPath(targetPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.running() && s.conf.Internal.Watch && !s.conf.Internal.DisableLiveReload {
|
if s.watching() && s.conf.Internal.Watch && !s.conf.Internal.DisableLiveReload {
|
||||||
pd.LiveReloadBaseURL = s.Conf.BaseURLLiveReload().URL()
|
pd.LiveReloadBaseURL = s.Conf.BaseURLLiveReload().URL()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ func newHugoSitesNew(cfg deps.DepsCfg, d *deps.Deps, sites []*Site) (*HugoSites,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only needed in server mode.
|
// Only needed in server mode.
|
||||||
if cfg.Configs.Base.Internal.Running {
|
if cfg.Configs.Base.Internal.Watch {
|
||||||
h.ContentChanges = &contentChangeMap{
|
h.ContentChanges = &contentChangeMap{
|
||||||
pathSpec: h.PathSpec,
|
pathSpec: h.PathSpec,
|
||||||
symContent: make(map[string]map[string]bool),
|
symContent: make(map[string]map[string]bool),
|
||||||
|
|
|
@ -486,6 +486,7 @@ func (s *sitesBuilder) LoadConfig() error {
|
||||||
flags := config.New()
|
flags := config.New()
|
||||||
flags.Set("internal", map[string]any{
|
flags.Set("internal", map[string]any{
|
||||||
"running": s.running,
|
"running": s.running,
|
||||||
|
"watch": s.running,
|
||||||
})
|
})
|
||||||
|
|
||||||
if s.workingDir != "" {
|
if s.workingDir != "" {
|
||||||
|
|
|
@ -5,12 +5,13 @@ stdout 'Pages.*|1'
|
||||||
stdout 'Total in'
|
stdout 'Total in'
|
||||||
checkfile public/index.html
|
checkfile public/index.html
|
||||||
checkfile public/p1/index.html
|
checkfile public/p1/index.html
|
||||||
|
grep 'IsServer: false' public/index.html
|
||||||
|
|
||||||
-- hugo.toml --
|
-- hugo.toml --
|
||||||
baseURL = "http://example.org/"
|
baseURL = "http://example.org/"
|
||||||
disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
|
disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
|
||||||
-- layouts/index.html --
|
-- layouts/index.html --
|
||||||
Home.
|
Home|IsServer: {{ .Site.IsServer }}|
|
||||||
-- layouts/_default/single.html --
|
-- layouts/_default/single.html --
|
||||||
Title: {{ .Title }}
|
Title: {{ .Title }}
|
||||||
-- content/p1.md --
|
-- content/p1.md --
|
||||||
|
|
Loading…
Reference in a new issue