2020-01-23 21:55:18 -05:00
|
|
|
import React from 'react';
|
2018-08-23 17:58:38 -04:00
|
|
|
import Helmet from 'react-helmet';
|
|
|
|
import { graphql, StaticQuery } from 'gatsby';
|
2020-01-23 21:55:18 -05:00
|
|
|
import { ThemeProvider } from 'emotion-theming';
|
2018-08-23 17:58:38 -04:00
|
|
|
import Header from './header';
|
|
|
|
import Footer from './footer';
|
2020-01-23 21:55:18 -05:00
|
|
|
import GlobalStyles from '../global-styles';
|
|
|
|
import theme from '../theme';
|
2018-08-23 17:58:38 -04:00
|
|
|
|
2020-01-23 21:55:18 -05:00
|
|
|
const LAYOUT_QUERY = graphql`
|
|
|
|
query layoutQuery {
|
|
|
|
site {
|
|
|
|
siteMetadata {
|
|
|
|
title
|
|
|
|
description
|
|
|
|
}
|
|
|
|
}
|
|
|
|
footer: file(relativePath: { regex: "/global/" }) {
|
|
|
|
childDataYaml {
|
|
|
|
footer {
|
|
|
|
buttons {
|
|
|
|
url
|
|
|
|
name
|
2018-08-23 17:58:38 -04:00
|
|
|
}
|
|
|
|
}
|
2020-01-23 21:55:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-02-19 16:55:10 -05:00
|
|
|
export const LayoutTemplate = ({ children }) => (
|
|
|
|
<ThemeProvider theme={theme}>
|
|
|
|
<GlobalStyles />
|
|
|
|
{children}
|
|
|
|
</ThemeProvider>
|
2020-02-20 16:38:34 +01:00
|
|
|
);
|
2020-02-19 16:55:10 -05:00
|
|
|
|
2020-01-23 21:55:18 -05:00
|
|
|
const Layout = ({ hasPageHero, children }) => {
|
|
|
|
return (
|
|
|
|
<StaticQuery query={LAYOUT_QUERY}>
|
2018-08-23 17:58:38 -04:00
|
|
|
{data => {
|
|
|
|
const { title, description } = data.site.siteMetadata;
|
|
|
|
|
|
|
|
return (
|
2020-02-19 16:55:10 -05:00
|
|
|
<LayoutTemplate
|
|
|
|
title={title}
|
|
|
|
description={description}
|
|
|
|
hasPageHero={hasPageHero}
|
|
|
|
footerButtons={data.footer.childDataYaml.footer.buttons}
|
|
|
|
>
|
2018-08-23 17:58:38 -04:00
|
|
|
<Helmet defaultTitle={title} titleTemplate={`%s | ${title}`}>
|
|
|
|
<meta name="description" content={description} />
|
2020-01-23 21:55:18 -05:00
|
|
|
<link
|
|
|
|
rel="stylesheet"
|
|
|
|
href="https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,700,900|Roboto+Mono:400,700"
|
|
|
|
/>
|
2018-08-23 17:58:38 -04:00
|
|
|
</Helmet>
|
2020-01-23 21:55:18 -05:00
|
|
|
<Header hasHeroBelow={hasPageHero} />
|
2018-08-23 17:58:38 -04:00
|
|
|
{children}
|
|
|
|
<Footer buttons={data.footer.childDataYaml.footer.buttons} />
|
2020-02-19 16:55:10 -05:00
|
|
|
</LayoutTemplate>
|
2018-08-23 17:58:38 -04:00
|
|
|
);
|
|
|
|
}}
|
|
|
|
</StaticQuery>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Layout;
|