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:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-07-12 13:47:14 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-07-13 11:56:23 +0300
commit9df98ec49ca9fa326125ccfee626b6e46c6ab14b (patch)
treecdfcfcc9522366d69b7b543638b689852a5e1252 /media
parent2fc33807077cd25bf91f2298bf1a8ace126881a7 (diff)
Add proper Media Type handling in js.Build
See #732
Diffstat (limited to 'media')
-rw-r--r--media/mediaType.go22
-rw-r--r--media/mediaType_test.go5
2 files changed, 18 insertions, 9 deletions
diff --git a/media/mediaType.go b/media/mediaType.go
index e33583a0e..8a2efc4a4 100644
--- a/media/mediaType.go
+++ b/media/mediaType.go
@@ -45,7 +45,6 @@ type Type struct {
Delimiter string `json:"delimiter"` // e.g. "."
- // TODO(bep) make this a string to make it hashable + method
Suffixes []string `json:"suffixes"`
// Set when doing lookup by suffix.
@@ -130,13 +129,17 @@ var (
CSVType = Type{MainType: "text", SubType: "csv", Suffixes: []string{"csv"}, Delimiter: defaultDelimiter}
HTMLType = Type{MainType: "text", SubType: "html", Suffixes: []string{"html"}, Delimiter: defaultDelimiter}
JavascriptType = Type{MainType: "application", SubType: "javascript", Suffixes: []string{"js"}, Delimiter: defaultDelimiter}
- JSONType = Type{MainType: "application", SubType: "json", Suffixes: []string{"json"}, Delimiter: defaultDelimiter}
- RSSType = Type{MainType: "application", SubType: "rss", mimeSuffix: "xml", Suffixes: []string{"xml"}, Delimiter: defaultDelimiter}
- XMLType = Type{MainType: "application", SubType: "xml", Suffixes: []string{"xml"}, Delimiter: defaultDelimiter}
- SVGType = Type{MainType: "image", SubType: "svg", mimeSuffix: "xml", Suffixes: []string{"svg"}, Delimiter: defaultDelimiter}
- TextType = Type{MainType: "text", SubType: "plain", Suffixes: []string{"txt"}, Delimiter: defaultDelimiter}
- TOMLType = Type{MainType: "application", SubType: "toml", Suffixes: []string{"toml"}, Delimiter: defaultDelimiter}
- YAMLType = Type{MainType: "application", SubType: "yaml", Suffixes: []string{"yaml", "yml"}, Delimiter: defaultDelimiter}
+ TypeScriptType = Type{MainType: "application", SubType: "typescript", Suffixes: []string{"ts"}, Delimiter: defaultDelimiter}
+ TSXType = Type{MainType: "text", SubType: "tsx", Suffixes: []string{"tsx"}, Delimiter: defaultDelimiter}
+ JSXType = Type{MainType: "text", SubType: "jsx", Suffixes: []string{"jsx"}, Delimiter: defaultDelimiter}
+
+ JSONType = Type{MainType: "application", SubType: "json", Suffixes: []string{"json"}, Delimiter: defaultDelimiter}
+ RSSType = Type{MainType: "application", SubType: "rss", mimeSuffix: "xml", Suffixes: []string{"xml"}, Delimiter: defaultDelimiter}
+ XMLType = Type{MainType: "application", SubType: "xml", Suffixes: []string{"xml"}, Delimiter: defaultDelimiter}
+ SVGType = Type{MainType: "image", SubType: "svg", mimeSuffix: "xml", Suffixes: []string{"svg"}, Delimiter: defaultDelimiter}
+ TextType = Type{MainType: "text", SubType: "plain", Suffixes: []string{"txt"}, Delimiter: defaultDelimiter}
+ TOMLType = Type{MainType: "application", SubType: "toml", Suffixes: []string{"toml"}, Delimiter: defaultDelimiter}
+ YAMLType = Type{MainType: "application", SubType: "yaml", Suffixes: []string{"yaml", "yml"}, Delimiter: defaultDelimiter}
// Common image types
PNGType = Type{MainType: "image", SubType: "png", Suffixes: []string{"png"}, Delimiter: defaultDelimiter}
@@ -165,6 +168,9 @@ var DefaultTypes = Types{
SASSType,
HTMLType,
JavascriptType,
+ TypeScriptType,
+ TSXType,
+ JSXType,
JSONType,
RSSType,
XMLType,
diff --git a/media/mediaType_test.go b/media/mediaType_test.go
index f18fd90bb..ee7d4407a 100644
--- a/media/mediaType_test.go
+++ b/media/mediaType_test.go
@@ -40,6 +40,9 @@ func TestDefaultTypes(t *testing.T) {
{CSVType, "text", "csv", "csv", "text/csv", "text/csv"},
{HTMLType, "text", "html", "html", "text/html", "text/html"},
{JavascriptType, "application", "javascript", "js", "application/javascript", "application/javascript"},
+ {TypeScriptType, "application", "typescript", "ts", "application/typescript", "application/typescript"},
+ {TSXType, "text", "tsx", "tsx", "text/tsx", "text/tsx"},
+ {JSXType, "text", "jsx", "jsx", "text/jsx", "text/jsx"},
{JSONType, "application", "json", "json", "application/json", "application/json"},
{RSSType, "application", "rss", "xml", "application/rss+xml", "application/rss+xml"},
{SVGType, "image", "svg", "svg", "image/svg+xml", "image/svg+xml"},
@@ -58,7 +61,7 @@ func TestDefaultTypes(t *testing.T) {
}
- c.Assert(len(DefaultTypes), qt.Equals, 23)
+ c.Assert(len(DefaultTypes), qt.Equals, 26)
}