}
}
-func (h *HugoSites) withSite(fn func(s *Site) error) error {
- for _, s := range h.Sites {
- if err := fn(s); err != nil {
- return err
- }
- }
- return nil
-}
-
func (h *HugoSites) withPage(fn func(s string, p *pageState) bool) {
- h.withSite(func(s *Site) error {
+ for s := range h.allSites(nil) {
w := &doctree.NodeShiftTreeWalker[contentNode]{
Tree: s.pageMap.treePages,
LockType: doctree.LockTypeRead,
return radix.WalkContinue, nil
},
}
- return w.Walk(context.Background())
- })
+ _ = w.Walk(context.Background())
+ }
}
// BuildCfg holds build options used to, as an example, skip the render step.
b.AssertFileContent("public/v1/p1/index.html", "Title: P1 from theme|Version: v1|")
}
+
+func TestSitesMatrixVersionsEditTemplate(t *testing.T) {
+ files := `
+-- hugo.toml --
+defaultcontentVersion = "v1"
+defaultcontentVersionInSubDir = true
+[versions]
+[versions."v1"]
+[versions."v2"]
+-- layouts/all.html --
+Version: {{ .Site.Version.Name }}|
+`
+
+ b := hugolib.TestRunning(t, files)
+
+ b.AssertFileContent("public/v1/index.html", "Version: v1|")
+
+ b.EditFileReplaceAll("layouts/all.html", "Version:", "Edited version:").Build()
+
+ b.AssertFileContent("public/v1/index.html", "Edited version: v1|")
+}