jaketrent / html-webpack-template

a better default template for html-webpack-plugin
MIT License
830 stars 139 forks source link

Allows users to specify custom meta tags by converting the meta options from an object to an array of objects #39

Closed joepin closed 7 years ago

joepin commented 7 years ago

First of all, thank you for such an excellent package! I'm new to web dev, and really appreciate tools such as this that drastically simplify the learning experience.

The reason I'm making this request is because I am currently in a situation where I'd like to insert custom meta tags, and specify multiple attributes per tag. I found the template to be limiting in that respect, since it defaults to inserting the KV pairs from the meta object into a tag as the name and content of the new tag.

My new code simply adds a conditional in the template file that checks if the meta option from the webpack config is an array, and if it is, builds out a dynamic meta tag based on the KVP's in each object in the array. If not, it performs exactly the same as always, saving this update from breaking existing code.

Please let me know what you think! I'd love to see this go into production, especially since I would like to use this personally.

jaketrent commented 7 years ago

I'm feeling slow to add this right away. Meta tags can have a couple other attributes, according to the docs. But the name and content attributes have worked and, I think, should work for most cases.

If your meta tags are custom, in what ways I'm not exactly sure, perhaps we should favor using a different, custom mechanism for showing them that might not fit into this general template.

I'll let this simmer for the moment. We'll see if there's any other demand for this from others with different use cases.

joepin commented 7 years ago

Totally hear you, and I concede that this is very much an edge case scenario, but I was looking to implement the open graph protocol on a client's site (OGP docs), and the OGP spec requires meta tags with a "property" attribute. I'm not sure how common this protocol is, but a quick search brought up this stat site, which, while neither conclusive nor authoritative, leads me to believe that it's a pretty nifty tool to support.

Forgive me if I come across as argumentative; I'm simply trying to explain why I think this feature is important to me. Again, I highly appreciate your hard work on this and thank you for your fast response. If you think of a better mechanism for implementing the OGP please let me know; I'd love to help bring this to life.

jaketrent commented 7 years ago

@joepin thanks for the extra info. It's good to understand the use case.

jaketrent commented 7 years ago

Weird that OGP uses property instead of name...

jaketrent commented 7 years ago

More I thought about this, the more I like the solution. Fits some of the weirdness of meta better. Thanks @joepin . Published in v6.0.0. Try it out, and let me know.

joepin commented 7 years ago

Awesome! Glad to hear!

I'll try it out in a little bit and get back to you.

Thank you!