Skip to content

Commit 9a2ad51

Browse files
committed
Matrix more
1 parent b254b31 commit 9a2ad51

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

‎hugolib/content_map_page.go‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ var (
666666
type contentNodeIs2 []contentNodeI
667667

668668
func (n contentNodeIs2) Dims() sitematrix.VectorProvider {
669-
panic("contentNodeIs2.Dims: not supported")
669+
panic("Dims(): not supported")
670670
}
671671

672672
func (n contentNodeIs2) Path() string {
@@ -793,9 +793,7 @@ func (s *contentNodeShifter) Delete(n contentNodeI, dims sitematrix.Vector) (con
793793
}
794794
return deleted, wasDeleted, isEmpty
795795
case contentNodeIs2:
796-
if len(v) == 0 {
797-
panic("empty contentNodeIs2")
798-
}
796+
// panic("TODO1 Delete")
799797
// TODO1 implement me.
800798
return nil, false, false
801799

@@ -897,9 +895,6 @@ func (s *contentNodeShifter) Shift(n contentNodeI, dims sitematrix.Vector, exact
897895
}
898896
return nil, false, 0
899897
case contentNodeIs2:
900-
if len(v) == 0 {
901-
panic("empty contentNodeIs2")
902-
}
903898
for _, vv := range v {
904899
if vv.Dims().HasVector(dims) {
905900
return vv, true, sitematrix.Language
@@ -984,6 +979,15 @@ func (s *contentNodeShifter) ForEeachInDimension(n contentNodeI, dims sitematrix
984979
}
985980
}
986981
}
982+
983+
case contentNodeIs2:
984+
for _, v := range vv {
985+
if v.Dims().HasVector(dims) {
986+
if f(v) {
987+
return
988+
}
989+
}
990+
}
987991
default:
988992
if n == nil {
989993
return
@@ -1094,7 +1098,7 @@ func (s *contentNodeShifter) Insert(old, new contentNodeI) (contentNodeI, conten
10941098
}*/
10951099

10961100
rs := append(vv, newp)
1097-
return contentNodeIs2(rs), vv.first(), false
1101+
return contentNodeIs2(rs), vv, false
10981102

10991103
case *resourceSource:
11001104
newp, ok := new.(*resourceSource)

‎hugolib/page__meta.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ params:
454454
pcfg := pm.pageConfig
455455
params := pcfg.Params
456456
if params == nil {
457-
panic("params not set for " + p.Title())
457+
panic("params not set for " + p.Path())
458458
}
459459

460460
var draft, published, isCJKLanguage *bool

‎hugolib/roles/roles_integration_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ site.GetPage p1: {{ with .Site.GetPage "p1" }}{{ .Title }}|{{ end }}$
263263
// b.AssertFileContent("public/en/index.html", "Title English", "Text English")
264264
b.AssertFileContent("public/v2.0.0/nn/p1/index.html", "Tittel Nynorsk", "Tekst Nynorsk", "site.GetPage p1: Tittel Nynorsk|")
265265
b.AssertFileContent("public/v2.0.0/nn/p2/index.html", "p2 all||", "site.GetPage p2: p2 all", "site.GetPage p1: Tittel Nynorsk|")
266-
b.AssertFileContent("public/v2.0.0/en/p2/index.html", "p2 all||", "sdf")
266+
b.AssertFileContent("public/v2.0.0/en/p2/index.html", "p2 all||", "site.GetPage p1: $")
267+
b.AssertFileContent("public/v2.0.0/nn/p2/index.html", "p2 all||", "site.GetPage p1: Tittel Nynorsk|$")
267268
b.AssertFileContent("public/v1.2.3/en/p2/index.html", "p2 all||", "site.GetPage p2: p2 all")
268269
}
269270

‎hugolib/sitematrix/sets.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ func (s *IntSets) EqualsVector(other VectorProvider) bool {
107107
})
108108
}
109109

110+
// ApplyDefaultsIfNotSet applies default values to the IntSets if they are not already set.
111+
func (s *IntSets) SetDefaultsIfNotSet(cfg ConfiguredDimensions) {
112+
if s.Languages == nil {
113+
s.Languages = maps.NewOrderedIntSet()
114+
s.Languages.Set(cfg.ConfiguredLanguages.IndexDefault())
115+
}
116+
if s.Versions == nil {
117+
s.Versions = maps.NewOrderedIntSet()
118+
s.Versions.Set(cfg.ConfiguredVersions.IndexDefault())
119+
}
120+
if s.Roles == nil {
121+
s.Roles = maps.NewOrderedIntSet()
122+
s.Roles.Set(cfg.ConfiguredRoles.IndexDefault())
123+
}
124+
}
125+
110126
func (s *IntSets) SetFrom(other *IntSets) {
111127
if other == nil {
112128
return

‎resources/page/pagemeta/page_frontmatter.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ func (p *PageConfig) CompileEearly(conf config.AllProvider, dimensionsFromFile *
329329
p.Languages = hstrings.UniqueStringsReuse(p.Languages)
330330
}
331331

332-
// TODO1 default when?
333332
sets, err := sitematrix.NewIntSets2(conf.ConfiguredDimensions(), false, p.Languages, p.Versions, p.Roles)
334333
if err != nil {
335334
return fmt.Errorf("failed to create dimensions sets: %w", err)
336335
}
337336
sets.SetFrom(dimensionsFromFile)
337+
sets.SetDefaultsIfNotSet(conf.ConfiguredDimensions())
338338
p.Dimensions = sets
339339

340340
setsDelegees, err := sitematrix.NewIntSets2(conf.ConfiguredDimensions(), false, p.LanguageDelegees, p.VersionDelegees, p.RoleDelegees)

0 commit comments

Comments
 (0)