diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-03-11 09:18:01 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-03-14 15:21:54 +0100 |
commit | ba1d0051b44fdd242b20899e195e37ab26501516 (patch) | |
tree | 646f815cf5eb027bae13e329696acf14d640d3f9 /hugolib | |
parent | 1b1dcf586e220c3a8ad5ecfa8e4c3dac97f0ab44 (diff) |
media: Make Type comparable
So we can use it and output.Format as map key etc.
This commit also fixes the media.Type implementation so it does not need to mutate itself to handle different suffixes for the same MIME type, e.g. jpg vs. jpeg.
This means that there are no Suffix or FullSuffix on media.Type anymore.
Fixes #8317
Fixes #8324
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/config_test.go | 10 | ||||
-rw-r--r-- | hugolib/pagebundler_test.go | 4 | ||||
-rw-r--r-- | hugolib/site.go | 2 | ||||
-rw-r--r-- | hugolib/site_output_test.go | 3 |
4 files changed, 10 insertions, 9 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go index aeeee5fa5..ecb450067 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -220,8 +220,9 @@ map[string]interface {}{ MainType: "text", SubType: "m1", Delimiter: ".", - Suffixes: []string{ - "m1main", + FirstSuffix: SuffixInfo{ + Suffix: "m1main", + FullSuffix: ".m1main", }, }, }, @@ -231,8 +232,9 @@ map[string]interface {}{ MainType: "text", SubType: "m2", Delimiter: ".", - Suffixes: []string{ - "m2theme", + FirstSuffix: SuffixInfo{ + Suffix: "m2theme", + FullSuffix: ".m2theme", }, }, }, diff --git a/hugolib/pagebundler_test.go b/hugolib/pagebundler_test.go index fc02d5857..7d775871a 100644 --- a/hugolib/pagebundler_test.go +++ b/hugolib/pagebundler_test.go @@ -34,8 +34,6 @@ import ( "github.com/gohugoio/hugo/htesting" - "github.com/gohugoio/hugo/media" - "github.com/gohugoio/hugo/deps" "github.com/spf13/viper" @@ -76,7 +74,7 @@ func TestPageBundlerSiteRegular(t *testing.T) { cfg.Set("outputFormats", map[string]interface{}{ "CUSTOMO": map[string]interface{}{ - "mediaType": media.HTMLType, + "mediaType": "text/html", "baseName": "cindex", "path": "cpath", "permalinkable": true, diff --git a/hugolib/site.go b/hugolib/site.go index d2a5e68ae..3c7c03bd1 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -913,7 +913,7 @@ type whatChanged struct { // package, so it will behave correctly with Hugo's built-in server. func (s *Site) RegisterMediaTypes() { for _, mt := range s.mediaTypesConfig { - for _, suffix := range mt.Suffixes { + for _, suffix := range mt.Suffixes() { _ = mime.AddExtensionType(mt.Delimiter+suffix, mt.Type()+"; charset=utf-8") } } diff --git a/hugolib/site_output_test.go b/hugolib/site_output_test.go index 5a329942c..1961dd06f 100644 --- a/hugolib/site_output_test.go +++ b/hugolib/site_output_test.go @@ -305,13 +305,14 @@ baseName = "customdelimbase" c.Assert(err, qt.IsNil) + s := h.Sites[0] + th.assertFileContent("public/_redirects", "a dotless") th.assertFileContent("public/defaultdelimbase.defd", "default delimim") // This looks weird, but the user has chosen this definition. th.assertFileContent("public/nosuffixbase", "no suffix") th.assertFileContent("public/customdelimbase_del", "custom delim") - s := h.Sites[0] home := s.getPage(page.KindHome) c.Assert(home, qt.Not(qt.IsNil)) |