set title on pages

This commit is contained in:
Nick Pegg 2017-10-14 10:17:16 -07:00
parent 064177fbf7
commit 9b14fc82be

View file

@ -2,6 +2,7 @@ import hljs from 'highlight.js';
import React, { Component } from 'react'; import React, { Component } from 'react';
import Markdown from 'react-markdown'; import Markdown from 'react-markdown';
import config from './config';
import { NotFound } from './NotFound'; import { NotFound } from './NotFound';
import { slugify } from './util'; import { slugify } from './util';
@ -51,6 +52,10 @@ class Page extends Component {
}); });
} }
componentWillUnmount() {
document.title = config.title;
}
componentWillReceiveProps(props) { componentWillReceiveProps(props) {
this.params = props.match.params; this.params = props.match.params;
this.fetchPage(); this.fetchPage();
@ -62,6 +67,7 @@ class Page extends Component {
} }
if (this.state.page) { if (this.state.page) {
document.title = `${config.title} - ${this.state.page.title}`;
return ( return (
<article> <article>
<header> <header>