Ergun
Ergun

Reputation: 520

GatsbyJS Layout.js returns error unexpected token

I am building a GatsbyJS website and created the layout.js, index.js with some static data and am trying to compile it but it does not compile. The code from layout.js and the error message are below.

import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import { StaticQuery, graphql } from 'gatsby'
import Header from './header'
import './theme.css'

const Layout = ({ children }) => (
  <StaticQuery
    query={graphql`
      query SiteTitleQuery {
        site {
          siteMetadata {
            title
          }
        }
      }
    `}
    render={data => (

        <Helmet
          title={data.site.siteMetadata.title}
          meta={[
            { name: 'description', content: 'Sample' },
            { name: 'keywords', content: 'sample, something' },
          ]}
        >

        <html lang="en" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="apple-touch-icon" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
        <link rel="shortcut icon" href="assets/ico/favicon.ico"/>

        // Font icon
        <link href="assets/css/plugin/font-awesome.min.css" rel="stylesheet" type="text/css" />  

        // CSS Global
        <link href="../../assets/css/plugin/bootstrap.min.css" rel="stylesheet" type="text/css" />  
        <link href="../../assets/css/plugin/bootstrap-select.min.css" rel="stylesheet" type="text/css" />   
        <link href="../../assets/css/plugin/owl.carousel.css" rel="stylesheet" type="text/css" />
        <link href="../../assets/css/plugin/animate.css" rel="stylesheet" type="text/css" /> 
        <link href="../../assets/css/plugin/subscribe-better.css" rel="stylesheet" type="text/css" />


        // Custom CSS 
        <link href="../../assets/css/theme.css" rel="stylesheet" type="text/css" />


        // Custom JS    
        <script src="../../assets/js/theme.js"></script>
        <script src="../../assets/js/plugin/jquery-2.2.4.min.js"></script>   
        <script src="../../assets/js/plugin/bootstrap.min.js"></script>
        <script src="../../assets/js/plugin/bootstrap-select.min.js"></script>
        <script src="../../assets/js/plugin/owl.carousel.min.js"></script>
        <script src="../../assets/js/plugin/jquery.plugin.min.js"></script>
        <script src="../../assets/js/plugin/jquery.countdown.js"></script>
        <script src="../../assets/js/plugin/isotope.js"></script>
        <script src="../../assets/js/plugin/jquery.subscribe-better.min.js"></script>
        <Helmet/>
        <Header siteTitle={data.site.siteMetadata.title} class="main-header"/>
        <div
          style={{
            margin: '0 auto',
            maxWidth: 960,
            padding: '0px 1.0875rem 1.45rem',
            paddingTop: 0,
          }}
        >
          {children}
        </div>
      )}
  />
)

Layout.propTypes = {
  children: PropTypes.node.isRequired,
}

export default Layout

It returns the error:

/home/ec2-user/environment/bestpet-v1/src/components/layout.js
  77:11  error  Parsing error: Unexpected token, expected "}"

  75 | 
  76 | Layout.propTypes = {
> 77 |   children: PropTypes.node.isRequired,
     |           ^
  78 | }
  79 | 
  80 | export default Layout

enter image description here

It does not compile at all. I checked all the brackets and closing tags but apparently I'm missing something.

What am I doing wrong?

Upvotes: 0

Views: 1632

Answers (1)

coreyward
coreyward

Reputation: 80140

You aren't closing your Helmet tag. Right now you have this:

<Helmet>
<OtherStuff />
<Helmet />

That last “tag” is self-closing, not closing the opening tag. What you want is this:

<Helmet>
  <OtherStuff />
</Helmet>

Upvotes: 1

Related Questions