package media
import "github.com/gohugoio/hugo/media"
Index ¶
- Variables
- type Type
- func FromString(t string) (Type, error)
- func (m Type) FullSuffix() string
- func (m Type) MarshalJSON() ([]byte, error)
- func (m Type) String() string
- func (m Type) Type() string
- type Types
Variables ¶
var ( CalendarType = Type{"text", "calendar", "ics", defaultDelimiter} CSSType = Type{"text", "css", "css", defaultDelimiter} CSVType = Type{"text", "csv", "csv", defaultDelimiter} HTMLType = Type{"text", "html", "html", defaultDelimiter} JavascriptType = Type{"application", "javascript", "js", defaultDelimiter} JSONType = Type{"application", "json", "json", defaultDelimiter} RSSType = Type{"application", "rss", "xml", defaultDelimiter} XMLType = Type{"application", "xml", "xml", defaultDelimiter} TextType = Type{"text", "plain", "txt", defaultDelimiter} )
var DefaultTypes = Types{ CalendarType, CSSType, CSVType, HTMLType, JavascriptType, JSONType, RSSType, XMLType, TextType, }
Types ¶
type Type ¶
type Type struct { MainType string `json:"mainType"` // i.e. text SubType string `json:"subType"` // i.e. html Suffix string `json:"suffix"` // i.e html Delimiter string `json:"delimiter"` // defaults to "." }
Type (also known as MIME type and content type) is a two-part identifier for file formats and format contents transmitted on the Internet. For Hugo's use case, we use the top-level type name / subtype name + suffix. One example would be image/jpeg+jpg If suffix is not provided, the sub type will be used. See // https://en.wikipedia.org/wiki/Media_type
func FromString ¶
FromString creates a new Type given a type sring on the form MainType/SubType and an optional suffix, e.g. "text/html" or "text/html+html".
func (Type) FullSuffix ¶
FullSuffix returns the file suffix with any delimiter prepended.
func (Type) MarshalJSON ¶
func (Type) String ¶
func (Type) Type ¶
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.
type Types ¶
type Types []Type
func DecodeTypes ¶
DecodeTypes takes a list of media type configurations and merges those, in the order given, with the Hugo defaults as the last resort.
func (Types) GetBySuffix ¶
GetBySuffix gets a media type given as suffix, e.g. "html". It will return false if no format could be found, or if the suffix given is ambiguous. The lookup is case insensitive.
func (Types) GetByType ¶
func (Types) Len ¶
func (Types) Less ¶
func (Types) Swap ¶
Source Files ¶
- Version
- v0.40.2
- Published
- Apr 30, 2018
- Platform
- js/wasm
- Imports
- 6 packages
- Last checked
- 1 minute ago –
Tools for package owners.