ember-meta
ember-meta copied to clipboard
RFC: {{meta}} helper
Hi @rwwagner90 :wave:
First of all, thank you oh-so-very-much for all the work you and your contributors have put into this project. I'm building a much needed new personal page with Prember and am using ember-meta to add metadata. It's working great!
Next, I'd like to run an idea by you that I keep thinking about. I'm sure you're familiar with ember-page-title, I'm using it in my personal site project as well to set the page titles. I really like the {{title}} helper that it provides and its semantics, and I'd love if I could use something similar for metadata.
Basically the thought is, the current semantics would not change. You can configure metadata globally still in config/environment.js as well as set the metadata from leaf routes, the key name aliases are great too. What I think would be interesting is that, if instead (or in addition to) this being taken care of by looking at the result of the model hook in the route. It could also be passed to a {{meta}} helper at the page level.
Here's an example:
app/
templates/
application.hbs
index.hbs
article.hbs
routes/
article.hbs
App-wide metadata defaults (currently go in config/environment.js):
{{! templates/application.hbs }}
{{meta
(hash
"siteName"="Carsten Nielsen"
"description"="Software developer specializing in web applications"
"imgSrc"="https://heycarsten.com/images/heycarsten.jpg"
"title"="Lead software developer, open learning, curious human"
"twitterUsername"="@heycarsten"
"url"="https://heycarsten.com"
)
}}
Leaf nodes would behave in a similar way, simply overriding existing metadata under the same keys:
{{! templates/article.hbs }}
{{! (assuming model coming from ember-cli-markdown-resolver) }}
{{meta model.attributes}}
{{markdown-to-html model.content}}
In cases where it is required to wipe out parent metadata:
{{meta model.attributes replace=true}} {{! in-line with ember-page-title }}
Let me know what your thoughts are on this, if it's confusing, already tried it, already done somewhere else, etc. If it interests you I'm happy to put in the work to make a nice big PR for it, but I didn't want to do that without running the initial idea by you first.
Have a great weekend and kick-ass 2019! :tada:
Hi @heycarsten! I am open to a helper, as long as all the existing functionality still works, and this just is another layer on top that overrides it. I believe this is what you are proposing? I'm definitely fine with giving the user options of how to set meta.
Yep, I'd consider existing functionality breaking to be a bug if this was implemented. I'll have some free cycles over the next few weeks, I'll fork and get started on a meta-helper branch. I'm sure stuff will come up as I work through things and I'll be sure to update this issue with anything I find. :v: Thanks, man!
Sounds good! Let me know if you need anything from me. Feel free to ping me on Discord as well.