media: Allow multiple file suffixes per media type
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 10 Jul 2018 09:55:22 +0000 (11:55 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 10 Jul 2018 20:13:52 +0000 (22:13 +0200)
commitb874a1ba7ab8394dc741c8c70303a30a35b63e43
tree756a5869cf623ace8387fcf6166a831c052f0ae7
parent4108705934846f2b7cae2602ce14aeee17139608
media: Allow multiple file suffixes per media type

Before this commit, `Suffix` on `MediaType` was used both to set a custom file suffix and as a way to augment the mediatype definition (what you see after the "+", e.g. "image/svg+xml").

This had its limitations. For one, it was only possible with one file extension per MIME type.

Now you can specify multiple file suffixes using "suffixes", but you need to specify the full MIME type
identifier:

[mediaTypes]
[mediaTypes."image/svg+xml"]
suffixes = ["svg", "abc ]

In most cases, it will be enough to just change:

[mediaTypes]
[mediaTypes."my/custom-mediatype"]
suffix = "txt"

To:

[mediaTypes]
[mediaTypes."my/custom-mediatype"]
suffixes = ["txt"]

Hugo will still respect values set in "suffix" if no value for "suffixes" is provided, but this will be removed in a future release.

Note that you can still get the Media Type's suffix from a template: {{ $mediaType.Suffix }}. But this will now map to the MIME type filename.

Fixes #4920
20 files changed:
hugolib/config_test.go
hugolib/page_output.go
hugolib/page_paths.go
hugolib/page_paths_test.go
hugolib/pagination_test.go
hugolib/shortcode.go
hugolib/site.go
hugolib/site_output_test.go
hugolib/site_render.go
media/mediaType.go
media/mediaType_test.go
output/docshelper.go
output/layout.go
output/layout_test.go
output/outputFormat.go
output/outputFormat_test.go
resource/bundler/bundler.go
resource/minifiers/minify.go
resource/resource.go
resource/resource_test.go