mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-19 06:51:32 +00:00
Proper parsing structured array from yaml based FrontMatter
This commit is contained in:
parent
e764a6e638
commit
29e786aac5
1 changed files with 14 additions and 4 deletions
|
@ -518,11 +518,21 @@ func (p *Page) update(f interface{}) error {
|
||||||
default: // handle array of strings as well
|
default: // handle array of strings as well
|
||||||
switch vvv := vv.(type) {
|
switch vvv := vv.(type) {
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
var a = make([]string, len(vvv))
|
if len(vvv) > 0 {
|
||||||
for i, u := range vvv {
|
switch vvv[0].(type) {
|
||||||
a[i] = cast.ToString(u)
|
case map[interface{}]interface{}: // Proper parsing structured array from yaml based FrontMatter
|
||||||
|
p.Params[loki] = vvv
|
||||||
|
default:
|
||||||
|
a := make([]string, len(vvv))
|
||||||
|
for i, u := range vvv {
|
||||||
|
a[i] = cast.ToString(u)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Params[loki] = a
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.Params[loki] = []string{}
|
||||||
}
|
}
|
||||||
p.Params[loki] = a
|
|
||||||
default:
|
default:
|
||||||
p.Params[loki] = vv
|
p.Params[loki] = vv
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue