mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 03:02:07 -05:00
parent
bc36d468ab
commit
a883948c4f
3 changed files with 14 additions and 7 deletions
|
@ -24,8 +24,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mime"
|
|
||||||
|
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/hugo/config"
|
"github.com/spf13/hugo/config"
|
||||||
|
@ -95,9 +93,6 @@ func init() {
|
||||||
|
|
||||||
serverCmd.RunE = server
|
serverCmd.RunE = server
|
||||||
|
|
||||||
mime.AddExtensionType(".json", "application/json; charset=utf-8")
|
|
||||||
mime.AddExtensionType(".css", "text/css; charset=utf-8")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func server(cmd *cobra.Command, args []string) error {
|
func server(cmd *cobra.Command, args []string) error {
|
||||||
|
@ -168,6 +163,10 @@ func server(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, s := range Hugo.Sites {
|
||||||
|
s.RegisterMediaTypes()
|
||||||
|
}
|
||||||
|
|
||||||
// Watch runs its own server as part of the routine
|
// Watch runs its own server as part of the routine
|
||||||
if serverWatch {
|
if serverWatch {
|
||||||
watchDirs := c.getDirList()
|
watchDirs := c.getDirList()
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
|
"mime"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -610,6 +611,15 @@ type whatChanged struct {
|
||||||
other bool
|
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.
|
// reBuild partially rebuilds a site given the filesystem events.
|
||||||
// It returns whetever the content source was changed.
|
// It returns whetever the content source was changed.
|
||||||
func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) {
|
func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) {
|
||||||
|
|
|
@ -177,5 +177,3 @@ func DecodeTypes(maps ...map[string]interface{}) (Types, error) {
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(bep) output mime.AddExtensionType
|
|
||||||
|
|
Loading…
Reference in a new issue