mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Add config.cascade
This commit adds support for using the `cascade` keyword in your configuration file(s), e.g. `config.toml`. Note that * Every feature of `cascade` is available, e.g. `_target` to target specific page sets. * Pages, e.g. the home page, can overwrite the cascade defined in config. Fixes #8741
This commit is contained in:
@@ -340,34 +340,10 @@ 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 {
|
||||
if v, err := maps.ToSliceStringMap(cv); err == nil {
|
||||
p.bucket.cascade = make(map[page.PageMatcher]maps.Params)
|
||||
|
||||
for _, vv := range v {
|
||||
var m page.PageMatcher
|
||||
if mv, found := vv["_target"]; found {
|
||||
err := page.DecodePageMatcher(mv, &m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
c, found := p.bucket.cascade[m]
|
||||
if found {
|
||||
// Merge
|
||||
for k, v := range vv {
|
||||
if _, found := c[k]; !found {
|
||||
c[k] = v
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.bucket.cascade[m] = vv
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
p.bucket.cascade = map[page.PageMatcher]maps.Params{
|
||||
{}: maps.ToStringMap(cv),
|
||||
}
|
||||
var err error
|
||||
p.bucket.cascade, err = page.DecodeCascade(cv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user