Skip to content

Instantly share code, notes, and snippets.

@pieterbeulque
Last active November 18, 2015 10:55
Show Gist options
  • Save pieterbeulque/c49d2bb353f9781981be to your computer and use it in GitHub Desktop.
Save pieterbeulque/c49d2bb353f9781981be to your computer and use it in GitHub Desktop.
fd-angular-meta SEO title helper
import { Inject } from 'fd-angular-core';
import { Page, Root } from 'mr-angular-pages';
import { Meta } from 'fd-angular-meta';
import TMPL from './application.html!';
@Page({
templateUrl: TMPL
})
export class ApplicationPage {
get longTitle () {
return this.long_title || this.title;
}
get seoTitle () {
let parent = this.parent,
title = 'Otentic';
while (!!parent && !!parent.title) {
if (parent.title === Root.title) {
break;
}
title = `${parent.title} | ${title}`;
parent = parent.parent || false;
}
if (this.title !== Root.title) {
title = `${this.title} | ${title}`;
}
return title;
}
@Meta
setMetaTags () {
return {
title: this.seoTitle
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment