mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
media, output: Add CSV type and format
And make CSS correclty behave as plain text.
This commit is contained in:
parent
05949c9038
commit
f911b107ef
4 changed files with 30 additions and 6 deletions
|
@ -49,6 +49,7 @@ func (m Type) String() string {
|
|||
var (
|
||||
CalendarType = Type{"text", "calendar", "ics"}
|
||||
CSSType = Type{"text", "css", "css"}
|
||||
CSVType = Type{"text", "csv", "csv"}
|
||||
HTMLType = Type{"text", "html", "html"}
|
||||
JavascriptType = Type{"application", "javascript", "js"}
|
||||
JSONType = Type{"application", "json", "json"}
|
||||
|
|
|
@ -30,6 +30,7 @@ func TestDefaultTypes(t *testing.T) {
|
|||
}{
|
||||
{CalendarType, "text", "calendar", "ics", "text/calendar", "text/calendar+ics"},
|
||||
{CSSType, "text", "css", "css", "text/css", "text/css+css"},
|
||||
{CSVType, "text", "csv", "csv", "text/csv", "text/csv+csv"},
|
||||
{HTMLType, "text", "html", "html", "text/html", "text/html+html"},
|
||||
{JavascriptType, "application", "javascript", "js", "application/javascript", "application/javascript+js"},
|
||||
{JSONType, "application", "json", "json", "application/json", "application/json+json"},
|
||||
|
|
|
@ -43,10 +43,18 @@ var (
|
|||
}
|
||||
|
||||
CSSFormat = Format{
|
||||
Name: "CSS",
|
||||
MediaType: media.CSSType,
|
||||
BaseName: "styles",
|
||||
Rel: "stylesheet",
|
||||
Name: "CSS",
|
||||
MediaType: media.CSSType,
|
||||
BaseName: "styles",
|
||||
IsPlainText: true,
|
||||
Rel: "stylesheet",
|
||||
}
|
||||
CSVFormat = Format{
|
||||
Name: "CSV",
|
||||
MediaType: media.CSVType,
|
||||
BaseName: "index",
|
||||
IsPlainText: true,
|
||||
Rel: "alternate",
|
||||
}
|
||||
|
||||
HTMLFormat = Format{
|
||||
|
|
|
@ -28,17 +28,31 @@ func TestDefaultTypes(t *testing.T) {
|
|||
require.True(t, CalendarFormat.IsPlainText)
|
||||
require.False(t, CalendarFormat.IsHTML)
|
||||
|
||||
require.Equal(t, "CSS", CSSFormat.Name)
|
||||
require.Equal(t, media.CSSType, CSSFormat.MediaType)
|
||||
require.Empty(t, CSSFormat.Path)
|
||||
require.Empty(t, CSSFormat.Protocol) // Will inherit the BaseURL protocol.
|
||||
require.True(t, CSSFormat.IsPlainText)
|
||||
require.False(t, CSSFormat.IsHTML)
|
||||
|
||||
require.Equal(t, "CSV", CSVFormat.Name)
|
||||
require.Equal(t, media.CSVType, CSVFormat.MediaType)
|
||||
require.Empty(t, CSVFormat.Path)
|
||||
require.Empty(t, CSVFormat.Protocol)
|
||||
require.True(t, CSVFormat.IsPlainText)
|
||||
require.False(t, CSVFormat.IsHTML)
|
||||
|
||||
require.Equal(t, "HTML", HTMLFormat.Name)
|
||||
require.Equal(t, media.HTMLType, HTMLFormat.MediaType)
|
||||
require.Empty(t, HTMLFormat.Path)
|
||||
require.Empty(t, HTMLFormat.Protocol) // Will inherit the BaseURL protocol.
|
||||
require.Empty(t, HTMLFormat.Protocol)
|
||||
require.False(t, HTMLFormat.IsPlainText)
|
||||
require.True(t, HTMLFormat.IsHTML)
|
||||
|
||||
require.Equal(t, "AMP", AMPFormat.Name)
|
||||
require.Equal(t, media.HTMLType, AMPFormat.MediaType)
|
||||
require.Equal(t, "amp", AMPFormat.Path)
|
||||
require.Empty(t, AMPFormat.Protocol) // Will inherit the BaseURL protocol.
|
||||
require.Empty(t, AMPFormat.Protocol)
|
||||
require.False(t, AMPFormat.IsPlainText)
|
||||
require.True(t, AMPFormat.IsHTML)
|
||||
|
||||
|
|
Loading…
Reference in a new issue