diff options
Diffstat (limited to 'deploy/deployConfig.go')
-rw-r--r-- | deploy/deployConfig.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/deploy/deployConfig.go b/deploy/deployConfig.go index ecfabb7a4..cc2b15280 100644 --- a/deploy/deployConfig.go +++ b/deploy/deployConfig.go @@ -20,6 +20,7 @@ import ( "github.com/gobwas/glob" "github.com/gohugoio/hugo/config" hglob "github.com/gohugoio/hugo/hugofs/glob" + "github.com/gohugoio/hugo/media" "github.com/mitchellh/mapstructure" ) @@ -31,7 +32,8 @@ type deployConfig struct { Matchers []*matcher Order []string - ordering []*regexp.Regexp // compiled Order + ordering []*regexp.Regexp // compiled Order + mediaTypes media.Types } type target struct { @@ -108,7 +110,12 @@ func (m *matcher) Matches(path string) bool { // decode creates a config from a given Hugo configuration. func decodeConfig(cfg config.Provider) (deployConfig, error) { - var dcfg deployConfig + + var ( + mediaTypesConfig []map[string]interface{} + dcfg deployConfig + ) + if !cfg.IsSet(deploymentConfigKey) { return dcfg, nil } @@ -134,5 +141,14 @@ func decodeConfig(cfg config.Provider) (deployConfig, error) { } dcfg.ordering = append(dcfg.ordering, re) } + + if cfg.IsSet("mediaTypes") { + mediaTypesConfig = append(mediaTypesConfig, cfg.GetStringMap("mediaTypes")) + } + + dcfg.mediaTypes, err = media.DecodeTypes(mediaTypesConfig...) + if err != nil { + return dcfg, err + } return dcfg, nil } |