summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-01-31 09:43:02 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-01-31 09:43:02 +0100
commit309d61b22064e59f17d3d8cc44b02d9007e24dcb (patch)
tree2500bf637ab4c71833ab99503a7a3725f385ab52
parent5b7cb258ec26d7de690099f5dc39935b8d728155 (diff)
output: Prevent setting Name directly in new output formats
Name is derived from the map key. Closes #11947
-rw-r--r--hugolib/site_output_test.go3
-rw-r--r--output/config.go2
-rw-r--r--output/outputFormat.go2
3 files changed, 3 insertions, 4 deletions
diff --git a/hugolib/site_output_test.go b/hugolib/site_output_test.go
index 9bcb13ea4..a68555574 100644
--- a/hugolib/site_output_test.go
+++ b/hugolib/site_output_test.go
@@ -330,8 +330,7 @@ func TestGetOutputFormatRel(t *testing.T) {
b := newTestSitesBuilder(t).
WithSimpleConfigFileAndSettings(map[string]any{
"outputFormats": map[string]any{
- "humansTXT": map[string]any{
- "name": "HUMANS",
+ "HUMANS": map[string]any{
"mediaType": "text/plain",
"baseName": "humans",
"isPlainText": true,
diff --git a/output/config.go b/output/config.go
index a7ebf5107..09d29f184 100644
--- a/output/config.go
+++ b/output/config.go
@@ -65,10 +65,10 @@ func DecodeConfig(mediaTypes media.Types, in any) (*config.ConfigNamespace[map[s
}
newOutFormat := defaultOutputFormat
- newOutFormat.Name = k
if err := decode(mediaTypes, v, &newOutFormat); err != nil {
return f, nil, err
}
+ newOutFormat.Name = k
f = append(f, newOutFormat)
diff --git a/output/outputFormat.go b/output/outputFormat.go
index 54e7fe98d..981d895b6 100644
--- a/output/outputFormat.go
+++ b/output/outputFormat.go
@@ -29,7 +29,7 @@ type Format struct {
// The Name is used as an identifier. Internal output formats (i.e. html and rss)
// can be overridden by providing a new definition for those types.
// <docsmeta>{ "identifiers": ["html", "rss"] }</docsmeta>
- Name string `json:"name"`
+ Name string `json:"-"`
MediaType media.Type `json:"-"`