2018-08-23 16:29:26 +01:00
|
|
|
import React, { Fragment, Component } from 'react';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
|
import Helmet from 'react-helmet';
|
|
|
|
|
import { StaticQuery, graphql } from 'gatsby';
|
|
|
|
|
|
|
|
|
|
import { fetchUser } from '../redux';
|
|
|
|
|
import Header from './Header';
|
|
|
|
|
import './layout.css';
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = () => ({});
|
2018-08-24 12:30:29 +01:00
|
|
|
const mapDispatchToProps = dispatch =>
|
|
|
|
|
bindActionCreators({ fetchUser }, dispatch);
|
2018-08-23 16:29:26 +01:00
|
|
|
|
|
|
|
|
class Layout extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.props.fetchUser();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { children, disableSettings } = this.props;
|
|
|
|
|
return (
|
|
|
|
|
<StaticQuery
|
|
|
|
|
query={graphql`
|
|
|
|
|
query SiteTitleQuery {
|
|
|
|
|
site {
|
|
|
|
|
siteMetadata {
|
|
|
|
|
title
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`}
|
|
|
|
|
render={data => (
|
|
|
|
|
<Fragment>
|
|
|
|
|
<Helmet
|
|
|
|
|
meta={[
|
|
|
|
|
{ name: 'description', content: 'Sample' },
|
|
|
|
|
{ name: 'keywords', content: 'sample, something' }
|
|
|
|
|
]}
|
|
|
|
|
title={data.site.siteMetadata.title}
|
2018-08-24 12:30:29 +01:00
|
|
|
/>
|
|
|
|
|
<Header disableSettings={disableSettings} />
|
|
|
|
|
<div style={{ marginTop: '38px' }}>{children}</div>
|
2018-08-23 16:29:26 +01:00
|
|
|
</Fragment>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Layout.propTypes = {
|
2018-08-24 12:30:29 +01:00
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
|
disableSettings: PropTypes.bool,
|
|
|
|
|
fetchUser: PropTypes.func.isRequired
|
2018-08-23 16:29:26 +01:00
|
|
|
};
|
|
|
|
|
|
2018-08-24 12:30:29 +01:00
|
|
|
export default connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps
|
|
|
|
|
)(Layout);
|