Skip to content

Commit

Permalink
output: Prevent setting Name directly in new output formats
Browse files Browse the repository at this point in the history
Name is derived from the map key.

Closes #11947
  • Loading branch information
bep committed Jan 31, 2024
1 parent 5b7cb25 commit 309d61b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions hugolib/site_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion output/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion output/outputFormat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`

Expand Down

0 comments on commit 309d61b

Please sign in to comment.