text: import React from 'react';
  import PropTypes from 'prop-types';
  import Helmet from 'react-helmet';
  
  import { useSiteMetaData } from '../hooks';
  
  function Seo({ description, lang, meta, keywords, title }) {
    const {
      title: defaultTitle,
      description: defaultDescription,
      image,
      author,
    } = useSiteMetaData();
    const siteTitle = `${title} | ${defaultTitle}`;
    const metaDescription = description || defaultDescription;
  
    return (
      <Helmet
        htmlAttributes={{
          lang,
        }}
        title={title}
        titleTemplate={`%s | ${defaultTitle}`}
        meta={[
          {
            name: 'description',
            content: metaDescription,
          },
          {
            property: 'og:title',
            content: siteTitle,
          },
          {
            property: 'og:description',
            content: metaDescription,
          },
          {
            property: 'og:type',
            content: 'website',
          },
          {
            property: 'og:image',
            content: image,
          },
          {
            name: 'twitter:card',
            content: 'summary',
          },
          {
            name: 'twitter:creator',
            content: author,
          },
          {
            name: 'twitter:title',
            content: siteTitle,
          },
          {
            name: 'twitter:description',
            content: metaDescription,
          },
          {
            name: 'twitter:image',
            content: image,
          },
        ]
          .concat(
            keywords.length > 0
              ? {
                  name: 'keywords',
                  content: keywords.join(', '),
                }
              : []
          )
          .concat(meta)}
      />
    );
  }
  
  Seo.defaultProps = {
    lang: 'en',
    meta: [],
    keywords: [],
  };
  
  Seo.propTypes = {
    description: PropTypes.string,
    lang: PropTypes.string,
    meta: PropTypes.array,
    keywords: PropTypes.arrayOf(PropTypes.string),
    title: PropTypes.string.isRequired,
  };
  
  export default Seo;
  