Set titles on post mount/unmount
This commit is contained in:
parent
4fce19a7bf
commit
064177fbf7
2 changed files with 8 additions and 4 deletions
|
|
@ -62,10 +62,6 @@ class App extends Component {
|
||||||
</Router>
|
</Router>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
document.title = config.title;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ScrollToTop extends Component {
|
class ScrollToTop extends Component {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class Post extends Component {
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
post: null,
|
post: null,
|
||||||
|
title: '',
|
||||||
notFound: false,
|
notFound: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -53,6 +54,11 @@ class Post extends Component {
|
||||||
this.fetchPost();
|
this.fetchPost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
// Reset the document title to the default
|
||||||
|
document.title = config.title;
|
||||||
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(props) {
|
componentWillReceiveProps(props) {
|
||||||
this.params = props.match.params;
|
this.params = props.match.params;
|
||||||
this.fetchPost();
|
this.fetchPost();
|
||||||
|
|
@ -64,6 +70,8 @@ class Post extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.post) {
|
if (this.state.post) {
|
||||||
|
console.log(this.state.post);
|
||||||
|
document.title = `${config.title} - ${this.state.post.title}`;
|
||||||
return (
|
return (
|
||||||
<Article
|
<Article
|
||||||
article={this.state.post}
|
article={this.state.post}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue