diff --git a/Our.Umbraco.TagHelpers/TagTagHelper.cs b/Our.Umbraco.TagHelpers/TagTagHelper.cs new file mode 100644 index 0000000..208fa76 --- /dev/null +++ b/Our.Umbraco.TagHelpers/TagTagHelper.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Razor.TagHelpers; +using Umbraco.Extensions; + +namespace Our.Umbraco.TagHelpers +{ + [HtmlTargetElement("*", Attributes = "our-tag")] + public class TagTagHelper : TagHelper + { + public string? OurTag { get; set; } + + public override void Process(TagHelperContext context, TagHelperOutput output) + { + if (OurTag?.IsNullOrWhiteSpace() == false) + { + output.TagName = OurTag.ToLower(); + } + } + } +} diff --git a/README.md b/README.md index a0f5850..cadb260 100644 --- a/README.md +++ b/README.md @@ -644,6 +644,37 @@ This will save the file as `/assets/alpinejs.js`, enabling eg. MIME types for .j ### Caching The file is saved once, and never updated unless you manually remove the file. The lookup for the local file is cached in the Runtime Cache. +## `our-tag` +This tag helper attribute can be seamlessly integrated with any DOM element within the Razor file. It allows content editors to oversee SEO by designating the appropriate HTML tags for distinct elements. Consider a scenario where you have an item in your block list named 'Heading Tag' - maybe it's from a predefined dropdown? This is saved as a straightforward string. Your block view then fetches this value through the model, making it accessible for the 'our-tag' tag helper. + +### Example 1 +``` +// Model.Heading = "This is my heading" +// Model.HeadingTag = "H1" +