mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
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
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
fdfa4a5fe6
commit
3400aff258
@@ -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 {
|
||||
|
Reference in New Issue
Block a user