mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 23:12:10 -05:00
Add handling of deeply nested front matter
This commit is contained in:
parent
4a8de8ea46
commit
69c1944f1f
2 changed files with 30 additions and 3 deletions
|
@ -247,6 +247,7 @@ func (p *Page) permalink() (*url.URL, error) {
|
||||||
|
|
||||||
if override, ok := p.Site.Permalinks[p.Section]; ok {
|
if override, ok := p.Site.Permalinks[p.Section]; ok {
|
||||||
permalink, err = override.Expand(p)
|
permalink, err = override.Expand(p)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -384,6 +385,8 @@ func (page *Page) update(f interface{}) error {
|
||||||
a[i] = cast.ToString(u)
|
a[i] = cast.ToString(u)
|
||||||
}
|
}
|
||||||
page.Params[loki] = a
|
page.Params[loki] = a
|
||||||
|
default:
|
||||||
|
page.Params[loki] = vv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/pkg/inflect"
|
"bitbucket.org/pkg/inflect"
|
||||||
|
"github.com/spf13/cast"
|
||||||
"github.com/spf13/hugo/helpers"
|
"github.com/spf13/hugo/helpers"
|
||||||
"github.com/spf13/hugo/source"
|
"github.com/spf13/hugo/source"
|
||||||
"github.com/spf13/hugo/target"
|
"github.com/spf13/hugo/target"
|
||||||
|
@ -60,7 +61,7 @@ type Site struct {
|
||||||
Taxonomies TaxonomyList
|
Taxonomies TaxonomyList
|
||||||
Source source.Input
|
Source source.Input
|
||||||
Sections Taxonomy
|
Sections Taxonomy
|
||||||
Info SiteInfo
|
Info *SiteInfo
|
||||||
Shortcodes map[string]ShortcodeFunc
|
Shortcodes map[string]ShortcodeFunc
|
||||||
timer *nitro.B
|
timer *nitro.B
|
||||||
Target target.Output
|
Target target.Output
|
||||||
|
@ -85,6 +86,29 @@ type SiteInfo struct {
|
||||||
Permalinks PermalinkOverrides
|
Permalinks PermalinkOverrides
|
||||||
Params map[string]interface{}
|
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 {
|
type runmode struct {
|
||||||
|
@ -292,7 +316,7 @@ func (s *Site) CreatePages() (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
page.Site = s.Info
|
page.Site = *s.Info
|
||||||
page.Tmpl = s.Tmpl
|
page.Tmpl = s.Tmpl
|
||||||
page.Section = file.Section
|
page.Section = file.Section
|
||||||
page.Dir = file.Dir
|
page.Dir = file.Dir
|
||||||
|
@ -648,7 +672,7 @@ func (s *Site) PrettifyPath(in string) string {
|
||||||
func (s *Site) NewNode() *Node {
|
func (s *Site) NewNode() *Node {
|
||||||
return &Node{
|
return &Node{
|
||||||
Data: make(map[string]interface{}),
|
Data: make(map[string]interface{}),
|
||||||
Site: s.Info,
|
Site: *s.Info,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue