diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/docshelper.go | 17 | ||||
-rw-r--r-- | media/mediaType.go | 14 |
2 files changed, 31 insertions, 0 deletions
diff --git a/media/docshelper.go b/media/docshelper.go new file mode 100644 index 000000000..9a84d5c7f --- /dev/null +++ b/media/docshelper.go @@ -0,0 +1,17 @@ +package media + +import ( + "github.com/spf13/hugo/docshelper" +) + +// This is is just some helpers used to create some JSON used in the Hugo docs. +func init() { + docsProvider := func() map[string]interface{} { + docs := make(map[string]interface{}) + + docs["types"] = DefaultTypes + return docs + } + + docshelper.AddDocProvider("media", docsProvider) +} diff --git a/media/mediaType.go b/media/mediaType.go index 942e9070e..6b6f90439 100644 --- a/media/mediaType.go +++ b/media/mediaType.go @@ -14,6 +14,7 @@ package media import ( + "encoding/json" "fmt" "sort" "strings" @@ -177,3 +178,16 @@ func DecodeTypes(maps ...map[string]interface{}) (Types, error) { return m, nil } + +func (t Type) MarshalJSON() ([]byte, error) { + type Alias Type + return json.Marshal(&struct { + Type string + String string + Alias + }{ + Type: t.Type(), + String: t.String(), + Alias: (Alias)(t), + }) +} |