mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +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
@@ -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|
|
||||
`)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user