Last active
November 18, 2015 10:55
-
-
Save pieterbeulque/c49d2bb353f9781981be to your computer and use it in GitHub Desktop.
fd-angular-meta SEO title helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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