diff options
author | Vas Sudanagunta <vas@commonkarma.org> | 2018-01-25 22:54:15 -0500 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-26 09:17:27 +0100 |
commit | 91bb774ae4e129f7ed0624754b31479c960ef774 (patch) | |
tree | 9c6d7628e9f5ec7c25842bb8609278da60ab2ec4 /commands | |
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 'commands')
-rw-r--r-- | commands/hugo.go | 4 | ||||
-rw-r--r-- | commands/import_jekyll.go | 2 | ||||
-rw-r--r-- | commands/undraft.go | 2 | ||||
-rw-r--r-- | commands/undraft_test.go | 2 |
4 files changed, 4 insertions, 6 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index 758106faf..c9f073483 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -1231,9 +1231,7 @@ func (c *commandeer) isThemeVsHugoVersionMismatch() (mismatch bool, requiredMinV return } - config := tomlMeta.(map[string]interface{}) - - if minVersion, ok := config["min_version"]; ok { + if minVersion, ok := tomlMeta["min_version"]; ok { return helpers.CompareVersion(minVersion) > 0, fmt.Sprint(minVersion) } diff --git a/commands/import_jekyll.go b/commands/import_jekyll.go index 98094dbb7..327bf6095 100644 --- a/commands/import_jekyll.go +++ b/commands/import_jekyll.go @@ -255,7 +255,7 @@ func loadJekyllConfig(fs afero.Fs, jekyllRoot string) map[string]interface{} { return nil } - return c.(map[string]interface{}) + return c } func createConfigFromJekyll(fs afero.Fs, inpath string, kind string, jekyllConfig map[string]interface{}) (err error) { diff --git a/commands/undraft.go b/commands/undraft.go index fbd2d4c3a..53861f456 100644 --- a/commands/undraft.go +++ b/commands/undraft.go @@ -99,7 +99,7 @@ func undraftContent(p parser.Page) (bytes.Buffer, error) { var isDraft, gotDate bool var date string L: - for k, v := range meta.(map[string]interface{}) { + for k, v := range meta { switch k { case "draft": if !v.(bool) { diff --git a/commands/undraft_test.go b/commands/undraft_test.go index 259e3479b..889f36567 100644 --- a/commands/undraft_test.go +++ b/commands/undraft_test.go @@ -69,7 +69,7 @@ func TestUndraftContent(t *testing.T) { t.Errorf("[%d] unexpected error %q", i, err) continue } - for k, v := range meta.(map[string]interface{}) { + for k, v := range meta { if k == "draft" { if v.(bool) { t.Errorf("[%d] Expected %q to be \"false\", got \"true\"", i, k) |