From: Piotr Kowalczuk
Date: Thu, 25 Jun 2015 09:46:09 +0000 (+0200)
Subject: Proper parsing structured array from yaml based FrontMatter
X-Git-Tag: v0.15~320
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=29e786aa;p=brevno-suite%2Fhugo
Proper parsing structured array from yaml based FrontMatter
---
diff --git a/hugolib/page.go b/hugolib/page.go
index 19408eee..385bf873 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -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
}