Updated PageTitle component

• Updated:
- PageTitle component
This commit is contained in:
mgabdev 2020-08-12 17:54:33 -05:00
parent adf4c49c82
commit 63c0f8c9fb

View File

@ -1,16 +1,7 @@
import isEqual from 'lodash.isequal' import isEqual from 'lodash.isequal'
import { APP_NAME } from '../../../constants'
export default class PageTitle extends PureComponent { class PageTitle extends PureComponent {
static propTypes = {
badge: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
path: PropTypes.oneOfType([
PropTypes.string,
PropTypes.array,
]),
}
componentDidMount() { componentDidMount() {
this.updatePageTitle(this.props) this.updatePageTitle(this.props)
@ -23,14 +14,12 @@ export default class PageTitle extends PureComponent {
} }
updatePageTitle = ({ badge, path}) => { updatePageTitle = ({ badge, path}) => {
const site = 'Gab'
let realPath = Array.isArray(path) ? path.join(' / ') : path let realPath = Array.isArray(path) ? path.join(' / ') : path
realPath = realPath.trim() realPath = realPath.trim()
const realBadge = !!badge ? `(${badge})` : '' const realBadge = !!badge ? `(${badge})` : ''
const title = `${realBadge} ${realPath} / ${site}`.trim() const title = `${realBadge} ${realPath} / ${APP_NAME}`.trim()
document.title = title document.title = title
} }
@ -38,4 +27,18 @@ export default class PageTitle extends PureComponent {
render() { render() {
return null return null
} }
} }
PageTitle.propTypes = {
badge: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
path: PropTypes.oneOfType([
PropTypes.string,
PropTypes.array,
]),
}
export default PageTitle