hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 69c1944f1fa78502aa3bd19ff59b2a96c8c7a6c4
parent 4a8de8ea46f45776518c7086222be0c94c893764
Author: spf13 <steve.francia@gmail.com>
Date:   Wed, 23 Apr 2014 02:55:43 -0400

Add handling of deeply nested front matter

Diffstat:
Mhugolib/page.go | 3+++
Mhugolib/site.go | 30+++++++++++++++++++++++++++---
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/hugolib/page.go b/hugolib/page.go
@@ -247,6 +247,7 @@ func (p *Page) permalink() (*url.URL, error) {
 
 	if override, ok := p.Site.Permalinks[p.Section]; ok {
 		permalink, err = override.Expand(p)
+
 		if err != nil {
 			return nil, err
 		}
@@ -384,6 +385,8 @@ func (page *Page) update(f interface{}) error {
 						a[i] = cast.ToString(u)
 					}
 					page.Params[loki] = a
+				default:
+					page.Params[loki] = vv
 				}
 			}
 		}
diff --git a/hugolib/site.go b/hugolib/site.go
@@ -24,6 +24,7 @@ import (
 	"time"
 
 	"bitbucket.org/pkg/inflect"
+	"github.com/spf13/cast"
 	"github.com/spf13/hugo/helpers"
 	"github.com/spf13/hugo/source"
 	"github.com/spf13/hugo/target"
@@ -60,7 +61,7 @@ type Site struct {
 	Taxonomies TaxonomyList
 	Source     source.Input
 	Sections   Taxonomy
-	Info       SiteInfo
+	Info       *SiteInfo
 	Shortcodes map[string]ShortcodeFunc
 	timer      *nitro.B
 	Target     target.Output
@@ -85,6 +86,29 @@ type SiteInfo struct {
 	Permalinks      PermalinkOverrides
 	Params          map[string]interface{}
 }
+
+func (s *SiteInfo) GetParam(key string) interface{} {
+	v := s.Params[strings.ToLower(key)]
+
+	if v == nil {
+		return nil
+	}
+
+	switch v.(type) {
+	case bool:
+		return cast.ToBool(v)
+	case string:
+		return cast.ToString(v)
+	case int64, int32, int16, int8, int:
+		return cast.ToInt(v)
+	case float64, float32:
+		return cast.ToFloat64(v)
+	case time.Time:
+		return cast.ToTime(v)
+	case []string:
+		return v
+	}
+	return nil
 }
 
 type runmode struct {
@@ -292,7 +316,7 @@ func (s *Site) CreatePages() (err error) {
 			if err != nil {
 				return err
 			}
-			page.Site = s.Info
+			page.Site = *s.Info
 			page.Tmpl = s.Tmpl
 			page.Section = file.Section
 			page.Dir = file.Dir
@@ -648,7 +672,7 @@ func (s *Site) PrettifyPath(in string) string {
 func (s *Site) NewNode() *Node {
 	return &Node{
 		Data: make(map[string]interface{}),
-		Site: s.Info,
+		Site: *s.Info,
 	}
 }