diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-22 11:03:42 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 15:43:56 +0200 |
commit | 4aaed87dd97b085b1505e53b7d4564aa8f7f18ef (patch) | |
tree | 4b11670db487dd255dbe6b12fe8cb3fefd7c3ff1 /media/mediaType.go | |
parent | c7dbee2321af2f0d61bdc976829681f3799582a9 (diff) |
hugolib, media: Make the MediaType available to the templates
Diffstat (limited to 'media/mediaType.go')
-rw-r--r-- | media/mediaType.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/media/mediaType.go b/media/mediaType.go index 877404ddc..45b850077 100644 --- a/media/mediaType.go +++ b/media/mediaType.go @@ -26,23 +26,24 @@ type Types []Type // If suffix is not provided, the sub type will be used. // See // https://en.wikipedia.org/wiki/Media_type type Type struct { - Type string // i.e. text - SubType string // i.e. html - Suffix string // i.e html + MainType string // i.e. text + SubType string // i.e. html + Suffix string // i.e html } -// Key return a key used to identify this media type. Hugo will register a set of -// default media types. These can be overridden by the user in the configuration, -// by defining a media type with the same Key. -func (m Type) Key() string { - return fmt.Sprintf("%s/%s", m.Type, m.SubType) +// Type returns a string representing the main- and sub-type of a media type, i.e. "text/css". +// Hugo will register a set of default media types. +// These can be overridden by the user in the configuration, +// by defining a media type with the same Type. +func (m Type) Type() string { + return fmt.Sprintf("%s/%s", m.MainType, m.SubType) } func (m Type) String() string { if m.Suffix != "" { - return fmt.Sprintf("%s/%s+%s", m.Type, m.SubType, m.Suffix) + return fmt.Sprintf("%s/%s+%s", m.MainType, m.SubType, m.Suffix) } - return fmt.Sprintf("%s/%s", m.Type, m.SubType) + return fmt.Sprintf("%s/%s", m.MainType, m.SubType) } var ( |