feat: SEO field types and the complete SEO tab
This commit is contained in:
@@ -89,16 +89,16 @@ func typeSettingsDocument(types []pact.MenuItemType) ([]byte, error) {
|
||||
}},
|
||||
yaml.MapItem{Key: base + "robots", Value: yaml.MapSlice{
|
||||
{Key: "label", Value: "golem15.seo::lang.settings.type_robots"},
|
||||
{Key: "type", Value: "dropdown"},
|
||||
{Key: "type", Value: "seorobots"},
|
||||
{Key: "scope", Value: "type"},
|
||||
{Key: "span", Value: "full"},
|
||||
{Key: "tab", Value: tab},
|
||||
}},
|
||||
yaml.MapItem{Key: base + "placeholders", Value: yaml.MapSlice{
|
||||
{Key: "type", Value: "partial"},
|
||||
{Key: "path", Value: "type_placeholders"},
|
||||
{Key: "span", Value: "full"},
|
||||
{Key: "tab", Value: tab},
|
||||
{Key: "options", Value: yaml.MapSlice{
|
||||
{Key: "", Value: "golem15.seo::lang.robots.site_default"},
|
||||
{Key: "index,follow", Value: "index, follow"},
|
||||
{Key: "noindex,follow", Value: "noindex, follow"},
|
||||
{Key: "index,nofollow", Value: "index, nofollow"},
|
||||
{Key: "noindex,nofollow", Value: "noindex, nofollow"},
|
||||
}},
|
||||
}},
|
||||
)
|
||||
}
|
||||
@@ -128,6 +128,14 @@ func (p *Plugin) typeSettingsTabs(types []pact.MenuItemType) *pact.AdminFormExte
|
||||
return &pact.AdminFormExtension{
|
||||
FieldsYAML: doc,
|
||||
Permissions: []string{controllers.PermissionManage},
|
||||
Dir: "extension",
|
||||
PartialData: func(ctx context.Context, name string, _ any) (any, error) {
|
||||
svc := p.Service()
|
||||
if svc == nil || name != "type_placeholders" {
|
||||
return nil, nil
|
||||
}
|
||||
return svc.Placeholders(ctx), nil
|
||||
},
|
||||
Load: func(ctx context.Context, in pact.AdminFormLoad) (map[string]any, error) {
|
||||
rows, err := classes.LoadTypeSettings(in.DB.WithContext(ctx))
|
||||
if err != nil {
|
||||
@@ -220,7 +228,11 @@ func (p *Plugin) saveTypeSettings(ctx context.Context, in pact.AdminFormSave, fi
|
||||
row.DescriptionTemplate = text
|
||||
}
|
||||
case "robots":
|
||||
row.Robots = strings.TrimSpace(stringOf(raw))
|
||||
normal, err := classes.NormalizeRobots(stringOf(raw))
|
||||
if err != nil {
|
||||
refusals[f.name] = append(refusals[f.name], controllers.Phrase(ctx, tr, "golem15.seo::lang.robots.invalid", nil))
|
||||
}
|
||||
row.Robots = normal
|
||||
}
|
||||
changed[f.key] = row
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user