Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MetaFields mapping to use RichText and Content Blocks etc. #114

Closed
robertjf opened this issue Sep 7, 2022 · 9 comments
Closed

Allow MetaFields mapping to use RichText and Content Blocks etc. #114

robertjf opened this issue Sep 7, 2022 · 9 comments

Comments

@robertjf
Copy link
Contributor

robertjf commented Sep 7, 2022

Currently when I configure the Meta Fields for a Document Type, the only properties that are showing up for mapping are TextString and TextArea type fields.

It would be great if we could map RichText and ContentBlock properties as well - particularly for the Meta/Social Description - in this case, SeoToolkit should extract the content and strip any html etc.; looking specifically for rich text/text properties and use the first one that it finds, truncating the rest.

@patrickdemooij9
Copy link
Owner

Hi @robertjf
Adding the RichText sounds like a logical inclusion. I'll make sure that one is added.
As for the ContentBlock properties, how would you see that working? As SeoToolkit doesn't know how you will render your ContentBlocks so it can't really predict how the HTML of that will look like.

It is possible to do this in code through one of the notifications: https://seotoolkit.gitbook.io/useotoolkit/extensions/notifications#beforemetatagsnotification. But if you have a suggestion for how it would work, then that would be great!

@robertjf
Copy link
Contributor Author

robertjf commented Sep 7, 2022

Hey @patrickdemooij9,

As a ContentBlock model is a structured json object, we can iteratively walk through the blocks looking for certain property types (after all, they are just IPublishedElements) and aggregate the first text strings that we find (including Rich text) until we have enough to satisfy the length of the meta field (title or description), truncating the rest.

This way, it wouldn't matter what the structure or layout of the blocks is at all - we can only take a best-guess as to what the editor is trying to convey in the page anyway :)

@patrickdemooij9
Copy link
Owner

Just so to double-check that we are thinking about the same thing.

If we have a page with a property (ContentBlock) called 'content' and the content of 'content' looks like this:

  • Hero
    • Title
    • Text
    • CallToAction
  • TextBlock
    • Title
    • Text
  • Form
    • Title
    • Form
  • TextBlock
    • Title
    • Text

We could have a way to select the first hero block with a special syntax (dunno if this is the best way to do it, but it'll work for this example). Something like content.Hero[0].Title, which will get the first Hero block in the content property and then the 'Title' property of that block.
And something like content.TextBlock.Text that will iterate all TextBlocks under 'content' and append the 'Text' property until the length is reached.

Is this what you were thinking about?

I think this would be quite cool, although making an interface for this might be a bit troubling but I am sure that can be done.

@robertjf
Copy link
Contributor Author

robertjf commented Sep 7, 2022

hey @patrickdemooij9,

I'd probably keep it simpler than that - while that would be cool, and possibly a future enhancement, for now perhaps we just walk the json tree looking for any property that represents a textstring / textbox / richtext and keep aggregating the content into a string (stripping html as we go) until we have enough content.

A slight enhancement for this would be to nominate what property types to look for the content in perhaps - that way you could use the same BlockList for both a title and a description field, and specify the Title uses a textstring, while the Description uses the RichText/Textbox... additional work would be necessary though in that the raw BlockList model doesn't expose the property type, just the alias and value.

@patrickdemooij9
Copy link
Owner

Yeah, that would probably be best for a first version, but it is good to hear that we are thinking about the same thing here 😊

I am sure I'll pick it up the future as well, but pull requests are always appreciated too!

@robertjf
Copy link
Contributor Author

robertjf commented Sep 7, 2022

yep, will see what I can do 👍🏻

robertjf added a commit to robertjf/SeoToolkit.Umbraco that referenced this issue Sep 19, 2023
…rich text values from a block list or grid for description meta fields
@robertjf
Copy link
Contributor Author

At the moment, the pull request only looks at top-level block list/grid items and extracts any text / text area / tinymce content it finds. It should probably also truncate the result based on a configurable value, but doesn't yet.

patrickdemooij9 pushed a commit that referenced this issue Sep 23, 2023
#235)

* #114 - this is a first attempt at getting the text or rich text values from a block list or grid for description meta fields

* Added checking for html encoded strings and stripping the html.
@robertjf
Copy link
Contributor Author

@patrickdemooij9 any idea on when you're likely to schedule a release? Itching to get these changes into production...

patrickdemooij9 pushed a commit that referenced this issue Oct 12, 2023
#235)

* #114 - this is a first attempt at getting the text or rich text values from a block list or grid for description meta fields

* Added checking for html encoded strings and stripping the html.
@patrickdemooij9
Copy link
Owner

@patrickdemooij9 any idea on when you're likely to schedule a release? Itching to get these changes into production...

Took a bit longer than expected, but it is out now: https://github.com/patrickdemooij9/SeoToolkit.Umbraco/releases/tag/3.4.0. Thanks again for your help on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants