Skip to content

Commit

Permalink
Move schema to different group and make keywords optional
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdemooij9 committed Jul 4, 2023
1 parent 4960afc commit e3ff369
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void Compose(IUmbracoBuilder builder)
builder.Services.Configure<MetaFieldsAppSettingsModel>(section);
builder.Services.AddSingleton(typeof(ISettingsService<MetaFieldsConfigModel>), typeof(MetaFieldsConfigurationService));

var disabledModules = section?.Get<MetaFieldsAppSettingsModel>()?.DisabledModules ?? Array.Empty<string>();
var settings = section?.Get<MetaFieldsAppSettingsModel>();
var disabledModules = settings?.DisabledModules ?? Array.Empty<string>();

if (disabledModules.Contains(DisabledModuleConstant.All))
{
Expand All @@ -67,8 +68,12 @@ public void Compose(IUmbracoBuilder builder)
.Add<OpenGraphImageField>()
.Add<CanonicalUrlField>()
.Add<RobotsField>()
.Add<SeoSchemaField>()
.Add<KeywordsField>();
.Add<SeoSchemaField>();

if (settings?.ShowKeywordsField is true)
{
builder.WithCollectionBuilder<SeoFieldCollectionBuilder>().Add<KeywordsField>();
}

builder.WithCollectionBuilder<SeoConverterCollectionBuilder>()
.Add<TextSeoValueConverter>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ public class MetaFieldsAppSettingsModel
public string[] SupportedMediaTypes { get; set; } = new[] { ".png", ".jpg", ".jpeg", ".webp", ".gif" };
public string OpenGraphCropAlias { get; set; } = "openGraphImage";
public string[] DisabledModules { get; set; } = Array.Empty<string>();

/// <summary>
/// Determines if the meta field keywords should be shown. Most search engines don't use it anymore.
/// </summary>
public bool ShowKeywordsField { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SeoSchemaField : ISeoField
public string Title => "Schema";
public string Alias => SeoFieldAliasConstants.Schema;
public string Description => "The schemas are a set of 'types', each associated with a set of properties. The types are arranged in a hierarchy.";
public string GroupAlias => SeoFieldGroupConstants.MetaFieldsGroup;
public string GroupAlias => SeoFieldGroupConstants.Others;
public Type FieldType => typeof(string);

public ISeoFieldEditor Editor => new SeoFieldFieldsEditor(new[] { "Umbraco.TextBox", "Umbraco.TextArea", "Umbraco.TinyMCE" });
Expand Down

0 comments on commit e3ff369

Please sign in to comment.