jsakamoto / Toolbelt.Blazor.HeadElement

Head element support (change the document title, "meta" elements such as OGP, and "link" elements) for Blazor apps.
https://demo-blazor-headelement.azurewebsites.net/
Mozilla Public License 2.0
159 stars 11 forks source link

Head elements output in random order #14

Open TheShrug opened 3 years ago

TheShrug commented 3 years ago

First off, thank you for this!

In troubleshooting some meta properties I noticed that they are rendered to the DOM in at least a semi-random order. Is there perhaps an option that I'm missing to output the order of elements in the order that they are declared in my razor pages?

If this isn't part of the feature-set and it is possible to do this, I would be glad to submit a pull request for it!

Thank you again, TheShrug

jsakamoto commented 3 years ago

Thank you for posting. Yes, this library renders meta/link elements as semi-random order. And this library doesn't provide a way to control the ordering of those elements.

This is one of the weak points of this library. I have been interested in this problem that how to resolve this issue since I produce this library. But I have never coming up with a cool idea to resolve this issue yet.

This problem is very hard to resolve smarty, I think. What is the "correct" ordering of the meta/link elements? How can developers control the ordering? Those are very deep consideration points on the code design.

If you have any cool ideas to resolve this issue, could you tell me your code design, before sending the pull request to me?

Alerinos commented 3 years ago

I think the first render should be from layout and the next from pages. Why so? Because we often load e.g. main.css and sometimes we want to fix the subpage, so to overwrite the changes, the css code must be loaded below the code from the layout.