mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
deep document title
This commit is contained in:
parent
3effd6dbdb
commit
efa3e7d795
@ -38,10 +38,6 @@ export default class App extends Component {
|
|||||||
router: React.PropTypes.object,
|
router: React.PropTypes.object,
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
|
||||||
document.title = `${this.getCurrentSection()} - Unleash Admin`;
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
// copied from https://github.com/react-mdl/react-mdl/issues/254
|
// copied from https://github.com/react-mdl/react-mdl/issues/254
|
||||||
// If our locations are different and drawer is open,
|
// If our locations are different and drawer is open,
|
||||||
@ -56,13 +52,7 @@ export default class App extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentSection () {
|
getSections () {
|
||||||
const { routes } = this.props;
|
|
||||||
const lastRoute = routes[routes.length - 1];
|
|
||||||
return lastRoute ? lastRoute.pageTitle : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
getTitleWithLinks () {
|
|
||||||
const { routes, params } = this.props;
|
const { routes, params } = this.props;
|
||||||
const unique = {};
|
const unique = {};
|
||||||
let result = [base].concat(routes.splice(1).map((routeEntry) => ({
|
let result = [base].concat(routes.splice(1).map((routeEntry) => ({
|
||||||
@ -76,9 +66,21 @@ export default class App extends Component {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// mutate document.title:
|
||||||
|
document.title = result
|
||||||
|
.reverse()
|
||||||
|
.map(e => e.name)
|
||||||
|
.join(' - ');
|
||||||
|
|
||||||
if (result.length > 2) {
|
if (result.length > 2) {
|
||||||
result = result.splice(1);
|
result = result.splice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTitleWithLinks () {
|
||||||
|
const result = this.getSections();
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{result.map((entry, index) => (
|
{result.map((entry, index) => (
|
||||||
|
Loading…
Reference in New Issue
Block a user