summaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/cascade_test.go54
-rw-r--r--hugolib/page__meta.go7
2 files changed, 57 insertions, 4 deletions
diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go
index 336acdcf3..a112fe10c 100644
--- a/hugolib/cascade_test.go
+++ b/hugolib/cascade_test.go
@@ -459,4 +459,58 @@ S1|p1:|p2:p2|
})
+ c.Run("slice with yaml _target", func(c *qt.C) {
+ b := newBuilder(c)
+
+ b.WithContent("_index.md", `---
+title: "Home"
+cascade:
+- p1: p1
+ _target:
+ path: "**p1**"
+- p2: p2
+ _target:
+ kind: "section"
+---
+`)
+
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/index.html", `
+P1|p1:p1|p2:|
+S1|p1:|p2:p2|
+`)
+
+ })
+
+ c.Run("slice with json _target", func(c *qt.C) {
+ b := newBuilder(c)
+
+ b.WithContent("_index.md", `{
+"title": "Home",
+"cascade": [
+ {
+ "p1": "p1",
+ "_target": {
+ "path": "**p1**"
+ }
+ },{
+ "p2": "p2",
+ "_target": {
+ "kind": "section"
+ }
+ }
+]
+}
+`)
+
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/index.html", `
+ P1|p1:p1|p2:|
+ S1|p1:|p2:p2|
+ `)
+
+ })
+
}
diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go
index 52ffbb880..d23718315 100644
--- a/hugolib/page__meta.go
+++ b/hugolib/page__meta.go
@@ -342,8 +342,7 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron
if p.bucket != nil {
// Check for any cascade define on itself.
if cv, found := frontmatter["cascade"]; found {
- switch v := cv.(type) {
- case []map[string]interface{}:
+ if v, err := maps.ToSliceStringMap(cv); err == nil {
p.bucket.cascade = make(map[page.PageMatcher]maps.Params)
for _, vv := range v {
@@ -367,12 +366,12 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron
}
}
- default:
+ } else {
p.bucket.cascade = map[page.PageMatcher]maps.Params{
page.PageMatcher{}: maps.ToStringMap(cv),
}
- }
+ }
}
}
} else {