mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
media: support application/manifest+json
The standard file extension for Web App Manifest files is ".webmanifest". This commit allows Hugo to recognize .webmanifest files as "application/manifest+json" files and to minify them using its JSON minifier. The .webmanifest file extension is recommended in the w3c spec to simplify media type registration: https://www.w3.org/TR/appmanifest/#media-type-registration Webhint docs are also relevant: https://webhint.io/docs/user-guide/hints/hint-manifest-file-extension/ Closes #8624
This commit is contained in:
parent
402da3f8f3
commit
02f31897b4
3 changed files with 19 additions and 8 deletions
|
@ -167,6 +167,7 @@ var (
|
||||||
JSXType = newMediaType("text", "jsx", []string{"jsx"})
|
JSXType = newMediaType("text", "jsx", []string{"jsx"})
|
||||||
|
|
||||||
JSONType = newMediaType("application", "json", []string{"json"})
|
JSONType = newMediaType("application", "json", []string{"json"})
|
||||||
|
WebAppManifestType = newMediaTypeWithMimeSuffix("application", "manifest", "json", []string{"webmanifest"})
|
||||||
RSSType = newMediaTypeWithMimeSuffix("application", "rss", "xml", []string{"xml"})
|
RSSType = newMediaTypeWithMimeSuffix("application", "rss", "xml", []string{"xml"})
|
||||||
XMLType = newMediaType("application", "xml", []string{"xml"})
|
XMLType = newMediaType("application", "xml", []string{"xml"})
|
||||||
SVGType = newMediaTypeWithMimeSuffix("image", "svg", "xml", []string{"svg"})
|
SVGType = newMediaTypeWithMimeSuffix("image", "svg", "xml", []string{"svg"})
|
||||||
|
@ -206,6 +207,7 @@ var DefaultTypes = Types{
|
||||||
TSXType,
|
TSXType,
|
||||||
JSXType,
|
JSXType,
|
||||||
JSONType,
|
JSONType,
|
||||||
|
WebAppManifestType,
|
||||||
RSSType,
|
RSSType,
|
||||||
XMLType,
|
XMLType,
|
||||||
SVGType,
|
SVGType,
|
||||||
|
|
|
@ -78,7 +78,7 @@ func New(mediaTypes media.Types, outputFormats output.Formats, cfg config.Provid
|
||||||
}
|
}
|
||||||
if !conf.DisableJSON {
|
if !conf.DisableJSON {
|
||||||
addMinifier(m, mediaTypes, "json", &conf.Tdewolff.JSON)
|
addMinifier(m, mediaTypes, "json", &conf.Tdewolff.JSON)
|
||||||
m.AddRegexp(regexp.MustCompile(`^(application|text)/(x-|ld\+)?json$`), &conf.Tdewolff.JSON)
|
m.AddRegexp(regexp.MustCompile(`^(application|text)/(x-|(ld|manifest)\+)?json$`), &conf.Tdewolff.JSON)
|
||||||
}
|
}
|
||||||
if !conf.DisableSVG {
|
if !conf.DisableSVG {
|
||||||
addMinifier(m, mediaTypes, "svg", &conf.Tdewolff.SVG)
|
addMinifier(m, mediaTypes, "svg", &conf.Tdewolff.SVG)
|
||||||
|
|
|
@ -143,6 +143,14 @@ var (
|
||||||
Rel: "alternate",
|
Rel: "alternate",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebAppManifestFormat = Format{
|
||||||
|
Name: "WebAppManifest",
|
||||||
|
MediaType: media.WebAppManifestType,
|
||||||
|
BaseName: "manifest",
|
||||||
|
IsPlainText: true,
|
||||||
|
Rel: "manifest",
|
||||||
|
}
|
||||||
|
|
||||||
RobotsTxtFormat = Format{
|
RobotsTxtFormat = Format{
|
||||||
Name: "ROBOTS",
|
Name: "ROBOTS",
|
||||||
MediaType: media.TextType,
|
MediaType: media.TextType,
|
||||||
|
@ -176,6 +184,7 @@ var DefaultFormats = Formats{
|
||||||
CSVFormat,
|
CSVFormat,
|
||||||
HTMLFormat,
|
HTMLFormat,
|
||||||
JSONFormat,
|
JSONFormat,
|
||||||
|
WebAppManifestFormat,
|
||||||
RobotsTxtFormat,
|
RobotsTxtFormat,
|
||||||
RSSFormat,
|
RSSFormat,
|
||||||
SitemapFormat,
|
SitemapFormat,
|
||||||
|
|
Loading…
Reference in a new issue