Skip to content

Commit

Permalink
Proper parsing structured array from yaml based FrontMatter
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrkowalczuk authored and bep committed Jun 25, 2015
1 parent e764a6e commit 29e786a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions hugolib/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,21 @@ func (p *Page) update(f interface{}) error {
default: // handle array of strings as well
switch vvv := vv.(type) {
case []interface{}:
var a = make([]string, len(vvv))
for i, u := range vvv {
a[i] = cast.ToString(u)
if len(vvv) > 0 {
switch vvv[0].(type) {
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:
p.Params[loki] = vv
}
Expand Down

0 comments on commit 29e786a

Please sign in to comment.