diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-06-20 08:45:52 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-06-20 11:04:14 +0200 |
commit | 0f40e1fadfca2276f65adefa6d7d5d63aef9160a (patch) | |
tree | 7bd0a02e660facfa8200ad3b9adf68ff3c7f3e3d /output/layout_test.go | |
parent | 516e6c6dc5733cdaf985317d58eedbc6ec0ef2f7 (diff) |
media, hugolib: Support extension-less media types
This change is motivated by Netlify's `_redirects` files, which is currently not possible to generate with Hugo.
This commit adds a `Delimiter` field to media type, which defaults to ".", but can be blanked out.
Fixes #3614
Diffstat (limited to 'output/layout_test.go')
-rw-r--r-- | output/layout_test.go | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/output/layout_test.go b/output/layout_test.go index 56aac00d5..9d4d2f6d5 100644 --- a/output/layout_test.go +++ b/output/layout_test.go @@ -21,14 +21,34 @@ import ( "github.com/stretchr/testify/require" ) -var ampType = Format{ - Name: "AMP", - MediaType: media.HTMLType, - BaseName: "index", -} - func TestLayout(t *testing.T) { + noExtNoDelimMediaType := media.TextType + noExtNoDelimMediaType.Suffix = "" + noExtNoDelimMediaType.Delimiter = "" + + noExtMediaType := media.TextType + noExtMediaType.Suffix = "" + + var ( + ampType = Format{ + Name: "AMP", + MediaType: media.HTMLType, + BaseName: "index", + } + + noExtDelimFormat = Format{ + Name: "NEM", + MediaType: noExtNoDelimMediaType, + BaseName: "_redirects", + } + noExt = Format{ + Name: "NEX", + MediaType: noExtMediaType, + BaseName: "next", + } + ) + for _, this := range []struct { name string d LayoutDescriptor @@ -39,6 +59,12 @@ func TestLayout(t *testing.T) { }{ {"Home", LayoutDescriptor{Kind: "home"}, true, "", ampType, []string{"index.amp.html", "index.html", "_default/list.amp.html", "_default/list.html", "theme/index.amp.html", "theme/index.html"}}, + {"Home, no ext or delim", LayoutDescriptor{Kind: "home"}, true, "", noExtDelimFormat, + []string{"index.nem", "_default/list.nem"}}, + {"Home, no ext", LayoutDescriptor{Kind: "home"}, true, "", noExt, + []string{"index.nex", "_default/list.nex"}}, + {"Page, no ext or delim", LayoutDescriptor{Kind: "page"}, true, "", noExtDelimFormat, + []string{"_default/single.nem", "theme/_default/single.nem"}}, {"Section", LayoutDescriptor{Kind: "section", Section: "sect1"}, false, "", ampType, []string{"section/sect1.amp.html", "section/sect1.html"}}, {"Taxonomy", LayoutDescriptor{Kind: "taxonomy", Section: "tag"}, false, "", ampType, |