Added custom title support

This commit is contained in:
2018-06-29 08:00:07 +10:00
parent 0ef9b02ff9
commit dfc78cf102
7 changed files with 62 additions and 13 deletions

View File

@ -22,9 +22,12 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import React from 'react';
import { connect } from 'react-redux';
import { Helmet } from "react-helmet";
import PageBoundary from './PageBoundary';
import Language from './../language/Language';
export default class Page extends React.Component {
class Page extends React.Component {
constructor(props) {
super(props);
}
@ -34,12 +37,36 @@ export default class Page extends React.Component {
if(this.props.className) clazzes += " " + this.props.className;
let title;
if(
(typeof this.props.title === typeof undefined ||
typeof this.props.title.length === typeof undefined ||
!this.props.title.length) && this.props.style != "home-page"
) {
console.exception("This page (" + (this.props.style || this.props.className) + ") does not have a title!");
} else {
title = <title>{ this.props.title }</title>
}
return (
<div className={clazzes}>
<Helmet defaultTitle={ Language.get("site.title") } titleTemplate={ Language.get("site.titleTemplate") }>
{ title }
</Helmet>
{ this.props.children }
</div>
);
}
}
export { PageBoundary };
const mapStateToProps = function(state) {
return {
code: state.language.code
}
}
export default connect(mapStateToProps)(Page);
export {
PageBoundary
}

View File

@ -24,6 +24,7 @@
import React from 'react';
import { connect } from 'react-redux';
import Page from './../Page';
import Language from './../../language/Language'
import BannerSection from './sections/BannerSection';
import PromoVideoSection from './sections/PromoVideoSection';
@ -34,7 +35,7 @@ import ExistingWorkSection from './sections/ExistingWorkSection';
const AboutPage = (props) => {
//Return
return (
<Page style="home-page" className="p-about-page">
<Page style="about-page" className="p-about-page" title={ Language.get("pages.about.title") }>
{ /* Banner */ }
<BannerSection />

View File

@ -43,7 +43,7 @@ class ContactPage extends React.Component {
render() {
return (
<Page style="contact-page" className="p-contact-page" title="">
<Page style="contact-page" className="p-contact-page" title={ Language.get("pages.contact.title") }>
<ClearSection />

View File

@ -35,7 +35,7 @@ export default function() {
}
return (
<Page style="home-page" className="p-home-page">
<Page style="home-page" title={0} className="p-home-page">
Welcome home
{ lines }
</Page>