Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/docshelper.go17
-rw-r--r--media/mediaType.go14
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),
+ })
+}