camelCase output format options

Fixes #114
This commit is contained in:
Bjørn Erik Pedersen 2017-07-31 16:55:41 +02:00
parent 902a14a185
commit 00f39bd78d
2 changed files with 185 additions and 129 deletions

View File

@ -26,7 +26,7 @@ A [media type][] (also known as *MIME type* and *content type*) is a two-part id
This is the full set of built-in media types in Hugo:
{{< datatable "media" "types" "Type" "Suffix" >}}
{{< datatable "media" "types" "type" "suffix" >}}
**Note:**
@ -55,7 +55,7 @@ Given a media type and some additional configuration, you get an `Output Format`
This is the full set of Hugo's built-in output formats:
{{< datatable "output" "formats" "Name" "MediaType" "Path" "BaseName" "Rel" "Protocol" "IsPlainText" "IsHTML" "NoUgly">}}
{{< datatable "output" "formats" "name" "mediaType" "path" "baseName" "rel" "protocol" "isPlainText" "isHTML" "noUgly">}}
* A page can be output in as many output formats as you want, and you can have an infinite amount of output formats defined **as long as they resolve to a unique path on the file system**. In the above table, the best example of this is `AMP` vs. `HTML`. `AMP` has the value `amp` for `Path` so it doesn't overwrite the `HTML` version; e.g. we can now have both `/index.html` and `/amp/index.html`.
* The `MediaType` must match the `Type` of an already defined media type.
@ -77,34 +77,34 @@ The above example is fictional, but if used for the homepage on a site with `bas
The following is the full list of configuration options for output formats and their default values:
`Name`
`name`
: the output format identifier. This is used to define what output format(s) you want for your pages.
`MediaType`
`mediaType`
: this must match the `Type` of a defined media type.
`Path`
`path`
: sub path to save the output files.
`BaseName`
`baseName`
: the base filename for the list filenames (homepage, etc.). **Default:** `index`.
`Rel`
`rel`
: can be used to create `rel` values in `link` tags. **Default:** `alternate`.
`Protocol`
`protocol`
: will replace the "http://" or "https://" in your `baseURL` for this output format.
`IsPlainText`
`isPlainText`
: use Go's plain text templates parser for the templates. **Default:** `false`.
`IsHTML`
`isHTML`
: used in situations only relevant for `HTML`-type formats; e.g., page aliases.
`NoUgly`
`noUgly`
: used to turn off ugly URLs If `uglyURLs` is set to `true` in your site. **Default:** `false`.
`NotAlternative`
`notAlternative`
: enable if it doesn't make sense to include this format in an `AlternativeOutputFormats` format listing on `Page` (e.g., with `CSS`). Note that we use the term *alternative* and not *alternate* here, as it does not necessarily replace the other format. **Default:** `false`.
## Output Formats for Pages

View File

@ -2,76 +2,76 @@
"media": {
"types": [
{
"Type": "application/javascript",
"String": "application/javascript+js",
"MainType": "application",
"SubType": "javascript",
"Suffix": "js",
"Delimiter": "."
"type": "application/javascript",
"string": "application/javascript+js",
"mainType": "application",
"subType": "javascript",
"suffix": "js",
"delimiter": "."
},
{
"Type": "application/json",
"String": "application/json+json",
"MainType": "application",
"SubType": "json",
"Suffix": "json",
"Delimiter": "."
"type": "application/json",
"string": "application/json+json",
"mainType": "application",
"subType": "json",
"suffix": "json",
"delimiter": "."
},
{
"Type": "application/rss",
"String": "application/rss+xml",
"MainType": "application",
"SubType": "rss",
"Suffix": "xml",
"Delimiter": "."
"type": "application/rss",
"string": "application/rss+xml",
"mainType": "application",
"subType": "rss",
"suffix": "xml",
"delimiter": "."
},
{
"Type": "application/xml",
"String": "application/xml+xml",
"MainType": "application",
"SubType": "xml",
"Suffix": "xml",
"Delimiter": "."
"type": "application/xml",
"string": "application/xml+xml",
"mainType": "application",
"subType": "xml",
"suffix": "xml",
"delimiter": "."
},
{
"Type": "text/calendar",
"String": "text/calendar+ics",
"MainType": "text",
"SubType": "calendar",
"Suffix": "ics",
"Delimiter": "."
"type": "text/calendar",
"string": "text/calendar+ics",
"mainType": "text",
"subType": "calendar",
"suffix": "ics",
"delimiter": "."
},
{
"Type": "text/css",
"String": "text/css+css",
"MainType": "text",
"SubType": "css",
"Suffix": "css",
"Delimiter": "."
"type": "text/css",
"string": "text/css+css",
"mainType": "text",
"subType": "css",
"suffix": "css",
"delimiter": "."
},
{
"Type": "text/csv",
"String": "text/csv+csv",
"MainType": "text",
"SubType": "csv",
"Suffix": "csv",
"Delimiter": "."
"type": "text/csv",
"string": "text/csv+csv",
"mainType": "text",
"subType": "csv",
"suffix": "csv",
"delimiter": "."
},
{
"Type": "text/html",
"String": "text/html+html",
"MainType": "text",
"SubType": "html",
"Suffix": "html",
"Delimiter": "."
"type": "text/html",
"string": "text/html+html",
"mainType": "text",
"subType": "html",
"suffix": "html",
"delimiter": "."
},
{
"Type": "text/plain",
"String": "text/plain+txt",
"MainType": "text",
"SubType": "plain",
"Suffix": "txt",
"Delimiter": "."
"type": "text/plain",
"string": "text/plain+txt",
"mainType": "text",
"subType": "plain",
"suffix": "txt",
"delimiter": "."
}
]
},
@ -79,87 +79,143 @@
"formats": [
{
"MediaType": "text/html+html",
"Name": "AMP",
"Path": "amp",
"BaseName": "index",
"Rel": "amphtml",
"Protocol": "",
"IsPlainText": false,
"IsHTML": true,
"NoUgly": false,
"NotAlternative": false
"name": "AMP",
"mediaType": {
"type": "text/html",
"string": "text/html+html",
"mainType": "text",
"subType": "html",
"suffix": "html",
"delimiter": "."
},
"path": "amp",
"baseName": "index",
"rel": "amphtml",
"protocol": "",
"isPlainText": false,
"isHTML": true,
"noUgly": false,
"notAlternative": false
},
{
"MediaType": "text/css+css",
"Name": "CSS",
"Path": "",
"BaseName": "styles",
"Rel": "stylesheet",
"Protocol": "",
"IsPlainText": true,
"IsHTML": false,
"NoUgly": false,
"NotAlternative": true
"name": "CSS",
"mediaType": {
"type": "text/css",
"string": "text/css+css",
"mainType": "text",
"subType": "css",
"suffix": "css",
"delimiter": "."
},
"path": "",
"baseName": "styles",
"rel": "stylesheet",
"protocol": "",
"isPlainText": true,
"isHTML": false,
"noUgly": false,
"notAlternative": true
},
{
"MediaType": "text/csv+csv",
"Name": "CSV",
"Path": "",
"BaseName": "index",
"Rel": "alternate",
"Protocol": "",
"IsPlainText": true,
"IsHTML": false,
"NoUgly": false,
"NotAlternative": false
"name": "CSV",
"mediaType": {
"type": "text/csv",
"string": "text/csv+csv",
"mainType": "text",
"subType": "csv",
"suffix": "csv",
"delimiter": "."
},
"path": "",
"baseName": "index",
"rel": "alternate",
"protocol": "",
"isPlainText": true,
"isHTML": false,
"noUgly": false,
"notAlternative": false
},
{
"MediaType": "text/calendar+ics",
"Name": "Calendar",
"Path": "",
"BaseName": "index",
"Rel": "alternate",
"Protocol": "webcal://",
"IsPlainText": true,
"IsHTML": false,
"NoUgly": false,
"NotAlternative": false
"name": "Calendar",
"mediaType": {
"type": "text/calendar",
"string": "text/calendar+ics",
"mainType": "text",
"subType": "calendar",
"suffix": "ics",
"delimiter": "."
},
"path": "",
"baseName": "index",
"rel": "alternate",
"protocol": "webcal://",
"isPlainText": true,
"isHTML": false,
"noUgly": false,
"notAlternative": false
},
{
"MediaType": "text/html+html",
"Name": "HTML",
"Path": "",
"BaseName": "index",
"Rel": "canonical",
"Protocol": "",
"IsPlainText": false,
"IsHTML": true,
"NoUgly": false,
"NotAlternative": false
"name": "HTML",
"mediaType": {
"type": "text/html",
"string": "text/html+html",
"mainType": "text",
"subType": "html",
"suffix": "html",
"delimiter": "."
},
"path": "",
"baseName": "index",
"rel": "canonical",
"protocol": "",
"isPlainText": false,
"isHTML": true,
"noUgly": false,
"notAlternative": false
},
{
"MediaType": "application/json+json",
"Name": "JSON",
"Path": "",
"BaseName": "index",
"Rel": "alternate",
"Protocol": "",
"IsPlainText": true,
"IsHTML": false,
"NoUgly": false,
"NotAlternative": false
"name": "JSON",
"mediaType": {
"type": "application/json",
"string": "application/json+json",
"mainType": "application",
"subType": "json",
"suffix": "json",
"delimiter": "."
},
"path": "",
"baseName": "index",
"rel": "alternate",
"protocol": "",
"isPlainText": true,
"isHTML": false,
"noUgly": false,
"notAlternative": false
},
{
"MediaType": "application/rss+xml",
"Name": "RSS",
"Path": "",
"BaseName": "index",
"Rel": "alternate",
"Protocol": "",
"IsPlainText": false,
"IsHTML": false,
"NoUgly": true,
"NotAlternative": false
"name": "RSS",
"mediaType": {
"type": "application/rss",
"string": "application/rss+xml",
"mainType": "application",
"subType": "rss",
"suffix": "xml",
"delimiter": "."
},
"path": "",
"baseName": "index",
"rel": "alternate",
"protocol": "",
"isPlainText": false,
"isHTML": false,
"noUgly": true,
"notAlternative": false
}
],
"layouts": [