mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
Add Data.Artifacts to css.Build and js.Build
Artifacts are the additional output files published as part of the build: source maps and files emitted by ESBuild's file loader (e.g. fonts). Each artifact provides Permalink, RelPermalink and MediaType, so e.g. font preload links can be constructed in templates. Also add media type definitions for source maps (application/source-map), font/woff and font/woff2. Fixes #15173 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+11
-2
@@ -21,6 +21,7 @@ type BuiltinTypes struct {
|
||||
TextType Type
|
||||
TOMLType Type
|
||||
YAMLType Type
|
||||
SourceMapType Type
|
||||
|
||||
// Common image types
|
||||
PNGType Type
|
||||
@@ -36,6 +37,8 @@ type BuiltinTypes struct {
|
||||
// Common font types
|
||||
TrueTypeFontType Type
|
||||
OpenTypeFontType Type
|
||||
WOFFFontType Type
|
||||
WOFF2FontType Type
|
||||
|
||||
// Common document types
|
||||
PDFType Type
|
||||
@@ -80,6 +83,7 @@ var Builtin = BuiltinTypes{
|
||||
TextType: Type{Type: "text/plain"},
|
||||
TOMLType: Type{Type: "application/toml"},
|
||||
YAMLType: Type{Type: "application/yaml"},
|
||||
SourceMapType: Type{Type: "application/source-map"},
|
||||
|
||||
// Common image types
|
||||
PNGType: Type{Type: "image/png"},
|
||||
@@ -95,6 +99,8 @@ var Builtin = BuiltinTypes{
|
||||
// Common font types
|
||||
TrueTypeFontType: Type{Type: "font/ttf"},
|
||||
OpenTypeFontType: Type{Type: "font/otf"},
|
||||
WOFFFontType: Type{Type: "font/woff"},
|
||||
WOFF2FontType: Type{Type: "font/woff2"},
|
||||
|
||||
// Common document types
|
||||
PDFType: Type{Type: "application/pdf"},
|
||||
@@ -139,6 +145,7 @@ var defaultMediaTypesConfig = map[string]any{
|
||||
"text/plain": map[string]any{"suffixes": []string{"txt"}},
|
||||
"application/toml": map[string]any{"suffixes": []string{"toml"}},
|
||||
"application/yaml": map[string]any{"suffixes": []string{"yaml", "yml"}},
|
||||
"application/source-map": map[string]any{"suffixes": []string{"map"}},
|
||||
|
||||
// Common image types
|
||||
"image/png": map[string]any{"suffixes": []string{"png"}},
|
||||
@@ -152,8 +159,10 @@ var defaultMediaTypesConfig = map[string]any{
|
||||
"image/heic": map[string]any{"suffixes": []string{"heic"}},
|
||||
|
||||
// Common font types
|
||||
"font/ttf": map[string]any{"suffixes": []string{"ttf"}},
|
||||
"font/otf": map[string]any{"suffixes": []string{"otf"}},
|
||||
"font/ttf": map[string]any{"suffixes": []string{"ttf"}},
|
||||
"font/otf": map[string]any{"suffixes": []string{"otf"}},
|
||||
"font/woff": map[string]any{"suffixes": []string{"woff"}},
|
||||
"font/woff2": map[string]any{"suffixes": []string{"woff2"}},
|
||||
|
||||
// Common document types
|
||||
"application/pdf": map[string]any{"suffixes": []string{"pdf"}},
|
||||
|
||||
@@ -142,6 +142,9 @@ func TestDefaultTypes(t *testing.T) {
|
||||
{Builtin.PDFType, "application", "pdf", "pdf", "application/pdf", "application/pdf"},
|
||||
{Builtin.TrueTypeFontType, "font", "ttf", "ttf", "font/ttf", "font/ttf"},
|
||||
{Builtin.OpenTypeFontType, "font", "otf", "otf", "font/otf", "font/otf"},
|
||||
{Builtin.WOFFFontType, "font", "woff", "woff", "font/woff", "font/woff"},
|
||||
{Builtin.WOFF2FontType, "font", "woff2", "woff2", "font/woff2", "font/woff2"},
|
||||
{Builtin.SourceMapType, "application", "source-map", "map", "application/source-map", "application/source-map"},
|
||||
} {
|
||||
c.Assert(test.tp.MainType, qt.Equals, test.expectedMainType)
|
||||
c.Assert(test.tp.SubType, qt.Equals, test.expectedSubType)
|
||||
@@ -151,5 +154,5 @@ func TestDefaultTypes(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
c.Assert(len(DefaultTypes), qt.Equals, 44)
|
||||
c.Assert(len(DefaultTypes), qt.Equals, 47)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user