ember-cli-document-title
ember-cli-document-title copied to clipboard
Fastboot initial title render
A repost of #43. The title in the html payload is the initial state and not the final state.
Is it known what work is required to get this working? Currently I think this issue is preventing the add-on from working correctly when used with ember-cli-staticboot with the includeClientScripts option disabled.
Is it known what work is required to get this working? Currently I think this issue is preventing the add-on from working correctly when used with ember-cli-staticboot with the includeClientScripts option disabled.
I don't think so. If you'd like to investigate, then please feel free to do so and share any findings here ❤️
I don't feel quite sure enough about how best to fix this but I believe I've identified the problem.
In document-title.js, collectTitleTokens ultimately calls setTitle when it reaches a route with title set. However, it calls the router's setTitle, which is set when Router is reopened lower down in that module, not the route's setTitle. I added
if(self.setTitle && typeof self.setTitle === 'function') {
self.setTitle(finalTitle);
}
right before the call to self.router.setTitle and it solved the problem, though perhaps there's some better option? Please advise and I'll be happy to submit a pull request.
@mminkoff I tried implementing what you did on my own fork but it did not appear to make a difference. Does this look correct to you?
https://github.com/Ravenstine/ember-cli-document-title/commit/7d5160b488d4e7886730acf19cb77a5f22c67a2f
I don't want to go down the more primitive root of using ember-cli-head.
That's correct @Ravenstine but yes it does depend on also using ember-cli-head (and adding setTitle to your route which then sets the title on the headData service.
If you don't use ember-cli-head then perhaps you'd have to use the method they use to affect what's in the head - the -in-element helper/component, which seems to be private/undocumented. See here: https://github.com/ronco/ember-cli-head/blob/master/addon/templates/components/head-layout.hbs
@mminkoff Confirmed to work when using ember-cli-head. You have no idea how much time you've saved me.
@Ravenstine So glad to hear it!! You have no idea how much time it took me to figure it out. :-)