diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-24 11:25:25 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 15:43:56 +0200 |
commit | 87188496fbb68c39567ec3ee3a55a9305a13e48b (patch) | |
tree | b70e4c3ce41c4d97fe70ce8cb06c4ee0e819084c /output | |
parent | 0c4701f0effbf651891979b925073f6fc5d26a82 (diff) |
hugolib, output: Handle aliases for all HTML formats
Diffstat (limited to 'output')
-rw-r--r-- | output/outputFormat.go | 6 | ||||
-rw-r--r-- | output/outputFormat_test.go | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/output/outputFormat.go b/output/outputFormat.go index c50d74f3f..2ef5fb62b 100644 --- a/output/outputFormat.go +++ b/output/outputFormat.go @@ -29,6 +29,7 @@ var ( BaseName: "index", Path: "amp", Rel: "amphtml", + IsHTML: true, } CalendarType = Format{ @@ -52,6 +53,7 @@ var ( MediaType: media.HTMLType, BaseName: "index", Rel: "canonical", + IsHTML: true, } JSONType = Format{ @@ -113,6 +115,10 @@ type Format struct { // as template parser. IsPlainText bool + // IsHTML returns whether this format is int the HTML family. This includes + // HTML, AMP etc. This is used to decide when to create alias redirects etc. + IsHTML bool + // Enable to ignore the global uglyURLs setting. NoUgly bool } diff --git a/output/outputFormat_test.go b/output/outputFormat_test.go index a76c50aee..5ef57f975 100644 --- a/output/outputFormat_test.go +++ b/output/outputFormat_test.go @@ -26,18 +26,29 @@ func TestDefaultTypes(t *testing.T) { require.Equal(t, "webcal://", CalendarType.Protocol) require.Empty(t, CalendarType.Path) require.True(t, CalendarType.IsPlainText) + require.False(t, CalendarType.IsHTML) require.Equal(t, "HTML", HTMLType.Name) require.Equal(t, media.HTMLType, HTMLType.MediaType) require.Empty(t, HTMLType.Path) require.Empty(t, HTMLType.Protocol) // Will inherit the BaseURL protocol. require.False(t, HTMLType.IsPlainText) + require.True(t, HTMLType.IsHTML) + + require.Equal(t, "AMP", AMPType.Name) + require.Equal(t, media.HTMLType, AMPType.MediaType) + require.Equal(t, "amp", AMPType.Path) + require.Empty(t, AMPType.Protocol) // Will inherit the BaseURL protocol. + require.False(t, AMPType.IsPlainText) + require.True(t, AMPType.IsHTML) require.Equal(t, "RSS", RSSType.Name) require.Equal(t, media.RSSType, RSSType.MediaType) require.Empty(t, RSSType.Path) require.False(t, RSSType.IsPlainText) require.True(t, RSSType.NoUgly) + require.False(t, CalendarType.IsHTML) + } func TestGetType(t *testing.T) { |