summaryrefslogtreecommitdiffhomepage
path: root/media
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2017-04-05 16:18:53 +0200
committerBjørn Erik Pedersen <[email protected]>2017-04-07 10:52:16 +0200
commit3c405f5172a6081483c9e5f4264a4d60e60bc8ac (patch)
treedbf2651314bfba7d6b8a8eaeb9f4acdd7814de5f /media
parent95808724595ab97042c204f3d92ea5c2929a8241 (diff)
downloadhugo-3c405f5172a6081483c9e5f4264a4d60e60bc8ac.tar.gz
hugo-3c405f5172a6081483c9e5f4264a4d60e60bc8ac.zip
all: Document the Output Formats feature
This commit also adds a new command, docshelper, with some utility funcs that adds a JSON datafiles to /docs/data that would be a pain to create and maintain by hand. Fixes #3242
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),
+ })
+}