Skip to content

Commit

Permalink
SeoSchema added to support schema.org scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Uğurhan Gül committed May 31, 2023
1 parent 776560b commit f4a5af4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Compose(IUmbracoBuilder builder)
}

builder.Components().Append<EnableModuleComponent>();

builder.Services.AddTransient(typeof(IRepository<DocumentTypeSettingsDto>), typeof(MetaFieldsSettingsDatabaseRepository));
builder.Services.AddTransient(typeof(IMetaFieldsSettingsService), typeof(MetaFieldsSettingsService));
builder.Services.AddTransient(typeof(IMetaFieldsService), typeof(MetaFieldsService));
Expand All @@ -67,6 +67,7 @@ public void Compose(IUmbracoBuilder builder)
.Add<OpenGraphImageField>()
.Add<CanonicalUrlField>()
.Add<RobotsField>()
.Add<SeoSchemaField>()
.Add<KeywordsField>();

builder.WithCollectionBuilder<SeoConverterCollectionBuilder>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public static class SeoFieldAliasConstants
{
public const string Title = "title";
public const string Keywords = "keywords";
public const string Schema = "schema";
public const string MetaDescription = "metaDescription";
public const string OpenGraphTitle = "openGraphTitle";
public const string OpenGraphDescription = "openGraphDescription";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using Microsoft.AspNetCore.Html;
using Umbraco.Cms.Core.Composing;
using SeoToolkit.Umbraco.MetaFields.Core.Common.SeoFieldEditEditors;
using SeoToolkit.Umbraco.MetaFields.Core.Constants;
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldEditors;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField
{
[Weight(200)]
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 Type FieldType => typeof(string);

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

public HtmlString Render(object value)
{
return new HtmlString($"<script type=\"application/ld+json\" />{value}</script>");
}
}
}

0 comments on commit f4a5af4

Please sign in to comment.