diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-04 18:05:19 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-04 18:05:19 +0200 |
commit | a883948c4fa6d6de9ef2912709b42655c4cead83 (patch) | |
tree | ffc83042567246ab31ff302a9ee89877669d00c3 /hugolib | |
parent | bc36d468ab56b5bcf01c3dc1478b1818dd17e4ff (diff) |
Register all media types when in server mode
Fixes #3274
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/site.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/hugolib/site.go b/hugolib/site.go index 7b5d0d156..aefc8c940 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -18,6 +18,7 @@ import ( "fmt" "html/template" "io" + "mime" "net/url" "os" "path/filepath" @@ -610,6 +611,15 @@ type whatChanged struct { other bool } +// RegisterMediaTypes will register the Site's media types in the mime +// package, so it will behave correctly with Hugo's built-in server. +func (s *Site) RegisterMediaTypes() { + for _, mt := range s.mediaTypesConfig { + // The last one will win if there are any duplicates. + mime.AddExtensionType("."+mt.Suffix, mt.Type()+"; charset=utf-8") + } +} + // reBuild partially rebuilds a site given the filesystem events. // It returns whetever the content source was changed. func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) { |