mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-18 02:52:09 +00:00
output: Prevent setting Name directly in new output formats
Name is derived from the map key. Closes #11947
This commit is contained in:
parent
5b7cb258ec
commit
309d61b220
3 changed files with 3 additions and 4 deletions
|
@ -330,8 +330,7 @@ func TestGetOutputFormatRel(t *testing.T) {
|
||||||
b := newTestSitesBuilder(t).
|
b := newTestSitesBuilder(t).
|
||||||
WithSimpleConfigFileAndSettings(map[string]any{
|
WithSimpleConfigFileAndSettings(map[string]any{
|
||||||
"outputFormats": map[string]any{
|
"outputFormats": map[string]any{
|
||||||
"humansTXT": map[string]any{
|
"HUMANS": map[string]any{
|
||||||
"name": "HUMANS",
|
|
||||||
"mediaType": "text/plain",
|
"mediaType": "text/plain",
|
||||||
"baseName": "humans",
|
"baseName": "humans",
|
||||||
"isPlainText": true,
|
"isPlainText": true,
|
||||||
|
|
|
@ -65,10 +65,10 @@ func DecodeConfig(mediaTypes media.Types, in any) (*config.ConfigNamespace[map[s
|
||||||
}
|
}
|
||||||
|
|
||||||
newOutFormat := defaultOutputFormat
|
newOutFormat := defaultOutputFormat
|
||||||
newOutFormat.Name = k
|
|
||||||
if err := decode(mediaTypes, v, &newOutFormat); err != nil {
|
if err := decode(mediaTypes, v, &newOutFormat); err != nil {
|
||||||
return f, nil, err
|
return f, nil, err
|
||||||
}
|
}
|
||||||
|
newOutFormat.Name = k
|
||||||
|
|
||||||
f = append(f, newOutFormat)
|
f = append(f, newOutFormat)
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ type Format struct {
|
||||||
// The Name is used as an identifier. Internal output formats (i.e. html and rss)
|
// 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.
|
// can be overridden by providing a new definition for those types.
|
||||||
// <docsmeta>{ "identifiers": ["html", "rss"] }</docsmeta>
|
// <docsmeta>{ "identifiers": ["html", "rss"] }</docsmeta>
|
||||||
Name string `json:"name"`
|
Name string `json:"-"`
|
||||||
|
|
||||||
MediaType media.Type `json:"-"`
|
MediaType media.Type `json:"-"`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue