fix: HTML sitemap headings follow each locale until an editor sets one
Settings > Sitemaps no longer prefills a content type's heading with its label in the administrator's language, so a save that did not touch the heading stores none and each locale's HTML sitemap keeps the label translated into it. The field's comment says so.
This commit is contained in:
@@ -80,6 +80,7 @@ func typeSettingsDocument(types []pact.MenuItemType) ([]byte, error) {
|
||||
}},
|
||||
yaml.MapItem{Key: base + "title", Value: yaml.MapSlice{
|
||||
{Key: "label", Value: "golem15.sitemap::lang.settings.type_title"},
|
||||
{Key: "comment", Value: "golem15.sitemap::lang.settings.type_title_comment"},
|
||||
{Key: "type", Value: "mltext"},
|
||||
{Key: "span", Value: "full"},
|
||||
{Key: "tab", Value: TabTypes},
|
||||
@@ -118,17 +119,18 @@ func (p *Plugin) typeSettingsTab(types []pact.MenuItemType) *pact.AdminFormExten
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
def := p.defaultLocale(ctx, in.DB)
|
||||
tr := p.translator()
|
||||
out := map[string]any{}
|
||||
for _, typ := range types {
|
||||
cfg := classes.EffectiveType(typ, rows)
|
||||
base := classes.TypeFieldBase(typ.Key)
|
||||
out[base+"include"] = cfg.Include
|
||||
out[base+"slug"] = cfg.Slug
|
||||
// Only stored headings (L2 WR-05): a type without one loads
|
||||
// empty, so a save that did not touch it stores none and each
|
||||
// locale's HTML sitemap keeps the label translated into it.
|
||||
titles := cfg.Titles
|
||||
if len(titles) == 0 {
|
||||
titles = map[string]string{def: controllers.Phrase(ctx, tr, typ.Label, nil)}
|
||||
if titles == nil {
|
||||
titles = map[string]string{}
|
||||
}
|
||||
out[base+"title"] = titles
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user