diff options
author | Bjørn Erik Pedersen <[email protected]> | 2017-04-05 16:18:53 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2017-04-07 10:52:16 +0200 |
commit | 3c405f5172a6081483c9e5f4264a4d60e60bc8ac (patch) | |
tree | dbf2651314bfba7d6b8a8eaeb9f4acdd7814de5f /output/outputFormat.go | |
parent | 95808724595ab97042c204f3d92ea5c2929a8241 (diff) | |
download | hugo-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 'output/outputFormat.go')
-rw-r--r-- | output/outputFormat.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/output/outputFormat.go b/output/outputFormat.go index ed3426411..bd0236278 100644 --- a/output/outputFormat.go +++ b/output/outputFormat.go @@ -14,6 +14,7 @@ package output import ( + "encoding/json" "fmt" "sort" "strings" @@ -299,6 +300,17 @@ func decode(mediaTypes media.Types, input, output interface{}) error { return decoder.Decode(input) } -func (t Format) BaseFilename() string { - return t.BaseName + "." + t.MediaType.Suffix +func (f Format) BaseFilename() string { + return f.BaseName + "." + f.MediaType.Suffix +} + +func (f Format) MarshalJSON() ([]byte, error) { + type Alias Format + return json.Marshal(&struct { + MediaType string + Alias + }{ + MediaType: f.MediaType.String(), + Alias: (Alias)(f), + }) } |