kimroen / ember-cli-document-title Goto Github PK
View Code? Open in Web Editor NEWAdding document title behaviour to your ember app
License: MIT License
Adding document title behaviour to your ember app
License: MIT License
In order to make sure that ember-cli-document-title
keeps working as intended with and without fastboot and before and after Glimmer 2, we need to add some tests for running it inside fastboot.
Some resources:
In fastboot, we just need to test the first render of everything, so we don't need as many tests as the normally running app does, luckily.
After updating to Ember 3.1 I've seen the following deprecation warning in our test suite logs:
DEPRECATION: Route#router is an intimate API that has been renamed to Route#_router. However you might want to consider using the router service [deprecation id: ember-routing.route-router] See https://emberjs.com/deprecations/v3.x#toc_ember-routing-route-router for more details.
It appears to be related to the use of self.router
at
Model is undefined when passed through 'titleToken' function in a route. Though I'm having model hook in the route. Don't know why?
Seems that the recent changes around the router service in Ember 3.7 breaks the add-on.
After upgrading I started to get this error:
Build Error (prember)
Cannot read property 'setTitle' of undefined
After digging through my node modules for setTitle
, the only hit was this add-on.
Hi there! First off, thanks a lot for this great add-on. I've been using it for a while and just found out a (minor) issue.
I have a models/foo.js
with an async
relationship to a user
such as:
export default DS.Model.extend({
title: DS.attr('string'),
user: DS.belongsTo('user', { async: true })
});
In my routes/foo.js
I have the following titleToken
:
export default Ember.Route.extend({
titleToken(model) {
return model.get('user.firstName');
}
});
Because user
is async, user.firstName
is undefined
at this point (user
is still a Promise
). When the promise is resolved, the title does not recompute so my title stays empty.
Would you have any recommendation about how to circumvent this issue? Thanks!
There are a number of open issues and PRs on this repo, and I believe there's desire for the community to help maintain it. May I propose we move this repo to its own org, and add some Admins to it to help drive it forward?
A common practice would be to create an org of the same name, and move it under.
ember-cli-document-title/ember-cli-document-title
The tests running on travis seems to have stopped working. Maybe something needs to be updated.
I'm seeing the following error with a lazy in-repo-engine:
Error: ENOENT: no such file or directory, open '/someproject/tmp/source_map_concat-input_base_path-OKV17DZi.tmp/vendor/document-title/document-title.js'
The in-repo-engine has the ember-cli-document-title
listed in the package.json
dependency field.
The current implementation has worked well for a long time, but:
Ember
global has been deprecatedAn alternative approach might be: deprecate this in favor of the framework-supplied ember-page-title
addon, which supports much of the same behavior.
Thanks for this project, it's awesome to not have to have @machty 's source just copy/pasted into our project anymore.
We originally modified the gist just slightly to allow automatically providing a page title in our Ember I18n translation file so we didn't need to create a route file simply to provide a title
or titleToken
.
To get it working with this add-on we made use of an initializer to support the auto-lookup. Something like this:
import Ember from 'ember';
export function initialize(/* container, application */) {
Ember.Route.reopen({
titleToken: Ember.computed('routeName', function() {
var pageTitleKey = `pageTitles.${this.get(routeName)}`;
if(Ember.I18n.exists(pageTitleKey)) {
return Ember.I18n.t(pageTitleKey);
}
})
});
}
export default {
name: 'route',
initialize: initialize
};
and then we provide a translation for the route name in our translations file, like this:
en = {
pageTitles: {
application: 'My Page Name'
...
}
}
I'm happy to keep-on-keepin' on with our custom re-open but I was curious if this sort of thing would be helpful for anyone else using this project.
I notice that you have ember-cli-babel listed as version 6.x in master but not in the latest release. Could you please release a version with babel 6?
Thanks!
This issue proposes sunsetting this addon in favor of ember-page-title. The last workable release would be 1.1.0
. Minor bump and updates to README will follow similar behaviour to ember-i18n
There are a number of reasons to consider this.
Please let me know in this issue if you have any thoughts or concerns!
This add-on is mentioned to support Ember Fastboot apps but I'm unable to see it actually work as expected. It does work normally when EmberJS is loaded, but when viewing the site source contents, the title is the same as written in "app/index.html" file. As a Ember Fastboot app I would expect for the title tag to change based on the configuration set. If this is a Fastboot issue, please disregard my issue. Thanks!
With 2.17.2 and earlier, everything worked without issue.
Upon upgrading to 2.18.0, the title
method never gets invoked.
The following deprecation is thrown on a new Ember 2.18.0
Version when starting the server. It seems some package needs to be updated.
This is not a reliable way to discover npm modules. Instead, consider doing: require("resolve").sync(something, { basedir: project.root }). Accessed from: new NPMDependencyVersionChecker (/Users/username/emberApp/node_modules/ember-cli-document-title/node_modules/ember-cli-version-checker/src/npm-dependency-version-checker.js:11:33)
Posting here for others to use.
Create a file in your project with the following contents
declare module 'ember' {
namespace Ember {
interface Route {
title: string;
}
}
}
Hello, I just created a new project with 0.1.5 installed this addon, the same way i installed in an older project, but the addon does not seem to apply itself correctly? none of the titles or title tokens get written to doc title. I'm not sure what changed? Maybe the addon package itself? or perhaps the routes and router changed somehow?
From #53
It has been reported that the latest release doesn't work on Ember 2.6. It has also been reported that it should, so we should figure that out.
Currently there is a problem when you try using addon inside other addon,
build will fail because of wrong parameter passed to included
function of addon,
see details:
ember-cli/ember-cli#3718
Repro:
sinon.rejects()
stub in it. Check that it passes.ember-cli-document-title
I have broken down what in the addon causes the error and traced it to this line:
var Promise = Ember.RSVP.Promise;
In vendor/document-title/document-title.js
.
I believe the problem is similar to what is described here:
Has anyone experienced this before? Or implemented any fixes? I'd imagine that the simplest fix is just to either remove the line completely and use native promises in the addon or change the name of the variable into which Ember.RSVP is imported.
Hello,
It could be quite useful to have access to the whole list of token in the router's setTitle method in order to make them accessible to a template, in order to output a structured breadcrumb.
// Stubbable fn that sets document.title
- this.router.setTitle(finalTitle);
+ this.router.setTitle(finalTitle, tokens);
Firstly, Thanks for the great plugin. I'm using this plugin to show a list, where I want to show the list count in the title. So, I tried .property()
on titleToken
function but It didn't work. I think we should add support for this functionality for dynamic title update.
Like this:
titleToken: function(model, params) {
return params.status_id;
}
A repost of #43. The title
in the html payload is the initial state and not the final state.
Here is the stack:
on-error.js:77 Error: Property set failed: object in path "_dom.document" could not be found or was destroyed.
at setPath (ember.debug.js:19288)
at Object.set (ember.debug.js:19208)
at Class.setTitle (document-title.js:85)
at Class.collectTitleTokens (document-title.js:65)
at Object.triggerEvent (ember.debug.js:26166)
at Object.trigger (ember.debug.js:53740)
at Object.trigger (ember.debug.js:52451)
at Class.send (ember.debug.js:25514)
at Class.updateTitle (document-title.js:77)
at Object.applyStr (ember.debug.js:20768)
I believe the problem is that container.lookup('renderer:-dom')
has changed it's structure and no longer has _dom
on it. See:
I'll see if I can figure out a solution and submit a PR.
This is a great little nifty library! I'm currently using it on https://www.ludu.co together with Prerender.io in order not to screw up SEO with Ember. :)
Do you have any plans on extending it to support for example description tags or Facebook's open graph tags? In my case, I would love to be able to set the og:image based on the model's image for example.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.