diff options
author | Gareth Watts <[email protected]> | 2020-10-22 12:14:14 -0500 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2020-10-22 23:00:19 +0200 |
commit | 3400aff2588cbf9dd4629c05537d16b019d0fdf5 (patch) | |
tree | e3714b454b2366f891cdfc746c5e9d9549d3a973 /hugolib/page__meta.go | |
parent | fdfa4a5fe62232f65f1dd8d6fe0c500374228788 (diff) | |
download | hugo-3400aff2588cbf9dd4629c05537d16b019d0fdf5.tar.gz hugo-3400aff2588cbf9dd4629c05537d16b019d0fdf5.zip |
Allow cascade _target to work with non toml fm
The TOML lib unmarshals slices of string maps to []map[string]interface{}
whereas YAML and JSON decode to []interface{}
The existing tests only check for TOML working correctly, and _target
with cascade did not work at all for frontmatter defined in other formats.
Add a function to normalize those slices
Fixes #7874
Diffstat (limited to 'hugolib/page__meta.go')
-rw-r--r-- | hugolib/page__meta.go | 7 |
1 files changed, 3 insertions, 4 deletions
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 { |