for {
select {
case changes := <-c.r.changesFromBuild:
+ c.errState.setBuildErr(nil)
unlock, err := h.LockBuild()
if err != nil {
c.r.logger.Errorln("Failed to acquire a build lock: %s", err)
c.r.logger.Errorln("Error while watching:", err)
}
if c.s != nil && c.s.doLiveReload {
- if c.changeDetector == nil || len(c.changeDetector.changed()) > 0 {
+ doReload := c.changeDetector == nil || len(c.changeDetector.changed()) > 0
+ doReload = doReload || c.showErrorInBrowser && c.errCount() > 0
+ if doReload {
livereload.ForceRefresh()
}
}
pt.AddChange(n.GetIdentity())
} else {
pt.AddChange(u.GetIdentity())
+ // New content not in use anywhere.
+ // To make sure that these gets listed in any site.RegularPages ranges or similar
+ // we could invalidate everything, but first try to collect a sample set
+ // from the surrounding pages.
+ var surroundingIDs []identity.Identity
+ ids := h.pageTrees.collectIdentitiesSurrounding(pi.Base(), 10)
+ if len(ids) > 0 {
+ surroundingIDs = append(surroundingIDs, ids...)
+ } else {
+ // No surrounding pages found, so invalidate everything.
+ surroundingIDs = []identity.Identity{identity.GenghisKhan}
+ }
+ for _, id := range surroundingIDs {
+ pt.AddChange(id)
+ }
}
}
}
if len(events) > 0 {
- // This is a rebuild
+ // This is a rebuild triggered from file events.
return h.processPartialFileEvents(ctx, l, config, init, events)
} else if len(config.WhatChanged.Changes()) > 0 {
+ // Rebuild triggered from remote events.
+ if err := init(config); err != nil {
+ return err
+ }
return h.processPartialRebuildChanges(ctx, l, config)
}
return h.processFull(ctx, l, config)
{{ $.AddPage (dict "kind" "page" "path" "p2" "title" "p2title" "dates" $dates "content" $contentHTML ) }}
{{ $.AddPage (dict "kind" "page" "path" "p3" "title" "p3title" "dates" $dates "content" $contentMarkdownDefault "draft" false ) }}
{{ $.AddPage (dict "kind" "page" "path" "p4" "title" "p4title" "dates" $dates "content" $contentMarkdownDefault "draft" $data.draft ) }}
+ADD_MORE_PLACEHOLDER
{{ $resourceContent := dict "value" $dataResource }}
b.AssertFileContent("public/index.html", "RegularPagesRecursive: p1:p1:/docs/p1|p3title:/docs/p3|p4title:/docs/p4|pfile:/docs/pfile|$")
}
+func TestPagesFromGoTmplAddPage(t *testing.T) {
+ t.Parallel()
+ b := hugolib.TestRunning(t, filesPagesFromDataTempleBasic)
+ b.EditFileReplaceAll("content/docs/_content.gotmpl", "ADD_MORE_PLACEHOLDER", `{{ $.AddPage (dict "kind" "page" "path" "page_added" "title" "page_added_title" "dates" $dates "content" $contentHTML ) }}`).Build()
+ b.AssertFileExists("public/docs/page_added/index.html", true)
+ b.AssertFileContent("public/index.html", "RegularPagesRecursive: p1:p1:/docs/p1|p2title:/docs/p2|p3title:/docs/p3|p4title:/docs/p4|page_added_title:/docs/page_added|pfile:/docs/pfile|$")
+}
+
func TestPagesFromGoTmplDraftPage(t *testing.T) {
t.Parallel()
b := hugolib.TestRunning(t, filesPagesFromDataTempleBasic)