From b874a1ba7ab8394dc741c8c70303a30a35b63e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 10 Jul 2018 11:55:22 +0200 Subject: 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 --- hugolib/config_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'hugolib/config_test.go') diff --git a/hugolib/config_test.go b/hugolib/config_test.go index aec673369..2fa26d4f3 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -219,8 +219,11 @@ map[string]interface {}{ "mediatype": Type{ MainType: "text", SubType: "m1", - Suffix: "m1main", + OldSuffix: "m1main", Delimiter: ".", + Suffixes: []string{ + "m1main", + }, }, }, "o2": map[string]interface {}{ @@ -228,8 +231,11 @@ map[string]interface {}{ "mediatype": Type{ MainType: "text", SubType: "m2", - Suffix: "m2theme", + OldSuffix: "m2theme", Delimiter: ".", + Suffixes: []string{ + "m2theme", + }, }, }, }`, got["outputformats"]) -- cgit v1.2.3