diff options
author | Vas Sudanagunta <vas@commonkarma.org> | 2018-01-26 06:54:15 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-26 11:17:27 +0300 |
commit | 91bb774ae4e129f7ed0624754b31479c960ef774 (patch) | |
tree | 9c6d7628e9f5ec7c25842bb8609278da60ab2ec4 /parser/page.go | |
parent | 3f0379adb72389954ca2be6a9f2ebfcd65c6c440 (diff) |
Support pages without front matter
* Page without front matter now treated same as a page with empty front matter.
* Test cases added to cover this and repro issue #4320.
* Type safety of front matter code improved.
Fixes #4320
Diffstat (limited to 'parser/page.go')
-rw-r--r-- | parser/page.go | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/parser/page.go b/parser/page.go index 1537915f4..17378840d 100644 --- a/parser/page.go +++ b/parser/page.go @@ -74,7 +74,7 @@ type Page interface { IsRenderable() bool // Metadata returns the unmarshalled frontmatter data. - Metadata() (interface{}, error) + Metadata() (map[string]interface{}, error) } // page implements the Page interface. @@ -100,16 +100,13 @@ func (p *page) IsRenderable() bool { } // Metadata returns the unmarshalled frontmatter data. -func (p *page) Metadata() (meta interface{}, err error) { +func (p *page) Metadata() (meta map[string]interface{}, err error) { frontmatter := p.FrontMatter() if len(frontmatter) != 0 { fm := DetectFrontMatter(rune(frontmatter[0])) if fm != nil { meta, err = fm.Parse(frontmatter) - if err != nil { - return - } } } return |