text: import React, { Component } from 'react'
  import Helmet from 'react-helmet'
  import urljoin from 'url-join'
  import config from '../../seoConfig'
  
  class Seo extends Component {
    render() {
      const { post, postSEO } = this.props
      let title
      let description
      let image
      let postUrl
  
      if (postSEO) {
        title = post.title
        description = post.description
        image = post.imgUrl
        postUrl = urljoin(config.siteUrl, config.pathPrefix, post.slug)
      } else {
        title = config.siteTitle
        description = config.siteDescription
        image = config.siteLogo
      }
  
      image = urljoin(config.siteUrl, config.pathPrefix, image)
      const siteUrl = urljoin(config.siteUrl, config.pathPrefix)
      const schemaOrgJSONLD = [
        {
          '@context': 'http://schema.org',
          '@type': 'WebSite',
          url: siteUrl,
          name: title,
          alternateName: config.siteTitleAlt ? config.siteTitleAlt : '',
        },
      ]
      if (postSEO) {
        schemaOrgJSONLD.push(
          {
            '@context': 'http://schema.org',
            '@type': 'BreadcrumbList',
            itemListElement: [
              {
                '@type': 'ListItem',
                position: 1,
                item: {
                  '@id': postUrl,
                  name: title,
                  image,
                },
              },
            ],
          },
          {
            '@context': 'http://schema.org',
            '@type': 'BlogPosting',
            url: siteUrl,
            name: title,
            alternateName: config.siteTitleAlt ? config.siteTitleAlt : '',
            headline: title,
            image: {
              '@type': 'ImageObject',
              url: image,
            },
            description,
          }
        )
      }
      return (
        <Helmet>
          {/* General tags */}
          <meta name="description" content={description} />
          <meta name="image" content={image} />
  
          {/* Schema.org tags */}
          <script type="application/ld+json">
            {JSON.stringify(schemaOrgJSONLD)}
          </script>
  
          {/* OpenGraph tags */}
          <meta property="og:url" content={postSEO ? postUrl : siteUrl} />
          {postSEO ? <meta property="og:type" content="article" /> : null}
          <meta property="og:title" content={title} />
          <meta property="og:description" content={description} />
          <meta property="og:image" content={image} />
  
          {/* Twitter Card tags */}
          <meta name="twitter:card" content="summary_large_image" />
          <meta
            name="twitter:creator"
            content={config.twitterHandle ? config.twitterHandle : ''}
          />
          <meta name="twitter:title" content={title} />
          <meta name="twitter:description" content={description} />
          <meta name="twitter:image" content={image} />
        </Helmet>
      )
    }
  }
  
  export default Seo
  