hugo: github.com/spf13/hugo/media Index | Files

package media

import "github.com/spf13/hugo/media"

Index

Package Files

docshelper.go mediaType.go

Variables

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"}
    RSSType        = Type{"application", "rss", "xml"}
    XMLType        = Type{"application", "xml", "xml"}
    TextType       = Type{"text", "plain", "txt"}
)
var DefaultTypes = Types{
    CalendarType,
    CSSType,
    CSVType,
    HTMLType,
    JavascriptType,
    JSONType,
    RSSType,
    XMLType,
    TextType,
}

type Type Uses

type Type struct {
    MainType string // i.e. text
    SubType  string // i.e. html
    Suffix   string // i.e html
}

A media 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 Uses

func FromString(t string) (Type, error)

FromTypeString 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) MarshalJSON Uses

func (t Type) MarshalJSON() ([]byte, error)

func (Type) String Uses

func (m Type) String() string

func (Type) Type Uses

func (m Type) Type() string

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 Uses

type Types []Type

func DecodeTypes Uses

func DecodeTypes(maps ...map[string]interface{}) (Types, error)

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 Uses

func (t Types) GetBySuffix(suffix string) (tp Type, found bool)

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 Uses

func (t Types) GetByType(tp string) (Type, bool)

func (Types) Len Uses

func (t Types) Len() int

func (Types) Less Uses

func (t Types) Less(i, j int) bool

func (Types) Swap Uses

func (t Types) Swap(i, j int)

Package media imports 6 packages (graph) and is imported by 8 packages. Updated 2017-04-28. Refresh now. Tools for package owners.