Vulcan/packages/telescope-seo/lib/routes.js

30 lines
788 B
JavaScript
Raw Normal View History

Meteor.startup(function() {
2015-03-24 10:11:11 -06:00
// Inject SEO tags.
Router.onAfterAction(function() {
var props = {meta: {}, og: {}};
var title = this.getTitle && this.getTitle();
2015-03-24 10:11:11 -06:00
var description = this.getDescription && this.getDescription();
2015-03-28 18:30:26 +09:00
var image = Settings.get("siteImage");
if (title) {
props.og.title = title;
}
if (description) {
props.meta.description = description;
props.og.description = description;
}
if (image) {
props.og.image = image;
}
SEO.set(props);
2015-03-24 10:11:11 -06:00
});
2015-03-24 10:11:11 -06:00
// Add canonical URL to post pages
Router.onAfterAction(function() {
2015-03-24 10:11:11 -06:00
var post = Posts.findOne(this.params._id);
if (post) {
SEO.set({link: {canonical: getPostPageUrl(post)}});
}
}, {only: ["post_page", "post_page_with_slug"]});
});