Register all media types when in server mode

Fixes #3274
This commit is contained in:
Bjørn Erik Pedersen
2017-04-04 18:05:19 +02:00
parent bc36d468ab
commit a883948c4f
3 changed files with 14 additions and 7 deletions

View File

@@ -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) {