diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-20 11:16:18 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-22 20:46:13 +0200 |
commit | 129c27ee6e9fed98dbfebeaa272fd52757b475b2 (patch) | |
tree | ba931600714e354f0c7d05ad0a598f591b0258f6 /hugolib/site.go | |
parent | 44da60d869578423dea529db62ed613588a2a560 (diff) |
parser/metadecoders: Consolidate the metadata decoders
See #5324
Diffstat (limited to 'hugolib/site.go')
-rw-r--r-- | hugolib/site.go | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/hugolib/site.go b/hugolib/site.go index 7f6ddce6c..cb980e8ab 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -44,6 +44,7 @@ import ( "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/media" + "github.com/gohugoio/hugo/parser/metadecoders" "github.com/markbates/inflect" @@ -53,7 +54,6 @@ import ( "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/hugolib/pagemeta" "github.com/gohugoio/hugo/output" - "github.com/gohugoio/hugo/parser" "github.com/gohugoio/hugo/related" "github.com/gohugoio/hugo/source" "github.com/gohugoio/hugo/tpl" @@ -949,16 +949,8 @@ func (s *Site) readData(f source.ReadableFile) (interface{}, error) { defer file.Close() content := helpers.ReaderToBytes(file) - switch f.Extension() { - case "yaml", "yml": - return parser.HandleYAMLData(content) - case "json": - return parser.HandleJSONData(content) - case "toml": - return parser.HandleTOMLMetaData(content) - default: - return nil, fmt.Errorf("Data not supported for extension '%s'", f.Extension()) - } + format := metadecoders.FormatFromString(f.Extension()) + return metadecoders.Unmarshal(content, format) } func (s *Site) readDataFromSourceFS() error { |