import React from "react"
import * as PropTypes from "prop-types"
import Helmet from "react-helmet"
import "../static/css/base.scss"

import InsetPage from "./inset-page"
import BlogPost from "./blog-post"

class MasterLayout extends React.Component {
  render() {
    let siteMetadata = this.props.data.allSite.edges[0].node.siteMetadata
    let location = this.props.location.pathname
    let jimmyPage // you jimmy a lock until it opens, so same thing here ;)

    // let dataSource = this.props.pageResources.json.data
    // let nodeType = dataSource.jsFrontmatter || dataSource.markdownRemark
    // let frontmatter = nodeType.data || nodeType.frontmatter
    let passdown = {
      // frontmatter: frontmatter,
      location: this.props.location,
      siteMetadata: siteMetadata,
      children: this.props.children,
    }
    if (location === `/` || location === `/contact`) {
      jimmyPage = <InsetPage {...passdown} />
    } else {
      jimmyPage = <BlogPost {...passdown} />
    }

    return (
      <div className="MasterLayout">
        <Helmet
          defaultTitle={siteMetadata.title}
          meta={[
            { name: `description`, content: siteMetadata.siteDescr },
            { name: `keywords`, content: `articles` },
          ]}
        />
        {jimmyPage}
      </div>
    )
  }
}

export default MasterLayout

export const pageQuery = graphql`
  query LayoutBySlug {
    allSite {
      edges {
        node {
          siteMetadata {
            title
            siteDescr
            siteAuthor
            siteEmailUrl
            siteEmailPretty
            siteTwitterUrl
            siteTwitterPretty
          }
        }
      }
    }
  }
`

@@ -301,28 +301,11 @@
 ata.
-allSite.edges%5B0%5D.nod
+sit
 e.si
@@ -1391,51 +1391,15 @@
     
-allS
+s
 ite %7B%0A
-      edges %7B%0A        node %7B%0A    
     
@@ -1423,20 +1423,16 @@
         
-    
 title%0A  
@@ -1433,28 +1433,24 @@
 tle%0A        
-  
-  
 siteDescr%0A  
@@ -1447,20 +1447,16 @@
 teDescr%0A
-    
         
@@ -1466,36 +1466,32 @@
 eAuthor%0A        
-    
 siteEmailUrl%0A   
@@ -1491,28 +1491,24 @@
 Url%0A        
- 
-   
 siteEmailPre
@@ -1511,36 +1511,32 @@
 lPretty%0A        
-   
- 
 siteTwitterUrl%0A 
@@ -1530,28 +1530,24 @@
 eTwitterUrl%0A
-    
         site
@@ -1564,30 +1564,8 @@
 tty%0A
-          %7D%0A        %7D%0A
     

Fix allSite query (#1946)