From efa3e7d7958271b73c8e11801c5786e7fab7ce16 Mon Sep 17 00:00:00 2001 From: sveisvei Date: Mon, 5 Dec 2016 17:15:55 +0100 Subject: [PATCH] deep document title --- frontend/src/component/app.jsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/frontend/src/component/app.jsx b/frontend/src/component/app.jsx index a1722fdd38..7bce5c799c 100644 --- a/frontend/src/component/app.jsx +++ b/frontend/src/component/app.jsx @@ -38,10 +38,6 @@ export default class App extends Component { router: React.PropTypes.object, } - componentDidMount () { - document.title = `${this.getCurrentSection()} - Unleash Admin`; - } - componentWillReceiveProps (nextProps) { // copied from https://github.com/react-mdl/react-mdl/issues/254 // If our locations are different and drawer is open, @@ -56,13 +52,7 @@ export default class App extends Component { } } - getCurrentSection () { - const { routes } = this.props; - const lastRoute = routes[routes.length - 1]; - return lastRoute ? lastRoute.pageTitle : ''; - } - - getTitleWithLinks () { + getSections () { const { routes, params } = this.props; const unique = {}; let result = [base].concat(routes.splice(1).map((routeEntry) => ({ @@ -76,9 +66,21 @@ export default class App extends Component { return false; }); + // mutate document.title: + document.title = result + .reverse() + .map(e => e.name) + .join(' - '); + if (result.length > 2) { result = result.splice(1); } + + return result; + } + + getTitleWithLinks () { + const result = this.getSections(); return ( {result.map((entry, index) => (