diff --git a/gatsby-config.js b/gatsby-config.js
index 3174f08..194b503 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -9,8 +9,9 @@ module.exports = {
siteMetadata: {
title: `Bonneville`,
titleTemplate: `%s | A starter theme for Gatsby`,
- siteUrl: `https://bonneville.netlify.com`,
description: `A starter theme for Gatsby`,
+ siteUrl: `https://bonneville.netlify.com`,
+ image: `/images/color.jpg`,
author: `Morgan Baker`,
authorSite: `https://www.morganbaker.dev`,
twitterUsername: `@bonneville`,
diff --git a/src/components/SEO.js b/src/components/SEO.js
index 13ac9a8..693b7df 100644
--- a/src/components/SEO.js
+++ b/src/components/SEO.js
@@ -1,54 +1,74 @@
import React from "react"
import { Helmet } from "react-helmet"
import PropTypes from "prop-types"
-import { StaticQuery, graphql } from "gatsby"
+import { useLocation } from "@reach/router"
+import { useStaticQuery, graphql } from "gatsby"
+
+const SEO = ({ title, description, lang, image, article }) => {
+ const { pathname } = useLocation()
+ const { site } = useStaticQuery(query)
+
+ const {
+ defaultTitle,
+ titleTemplate,
+ defaultDescription,
+ siteUrl,
+ defaultImage,
+ twitterUsername,
+ } = site.siteMetadata
+
+ const seo = {
+ title: title || defaultTitle,
+ description: description || defaultDescription,
+ image: `${siteUrl}${image || defaultImage}`,
+ url: `${siteUrl}${pathname}`,
+ }
+
+ return (
+
+
+
+ {seo.url && }
+ {(article ? true : null) && }
+ {seo.title && }
+ {seo.description && (
+
+ )}
+ {seo.image && }
+
+ {twitterUsername && (
+
+ )}
+ {seo.title && }
+ {seo.description && (
+
+ )}
+ {seo.image && }
+
+ )
+}
-const SEO = ({ title, description, image, pathname, article }) => (
- {
- const seo = {
- title: title || defaultTitle,
- description: description || defaultDescription,
- url: `${siteUrl}${pathname || "/"}`,
- }
- return (
- <>
-
-
- {seo.url && }
- {(article ? true : null) && (
-
- )}
- {seo.title && }
- {seo.description && (
-
- )}
-
- {twitterUsername && (
-
- )}
- {seo.title && }
- {seo.description && (
-
- )}
-
- >
- )
- }}
- />
-)
export default SEO
+
+SEO.propTypes = {
+ title: PropTypes.string,
+ description: PropTypes.string,
+ image: PropTypes.string,
+ article: PropTypes.bool,
+}
+
+SEO.defaultProps = {
+ title: null,
+ description: null,
+ image: null,
+ lang: `en`,
+ article: false,
+}
+
const query = graphql`
query SEO {
site {
@@ -57,22 +77,9 @@ const query = graphql`
titleTemplate
defaultDescription: description
siteUrl
+ defaultImage: image
twitterUsername
}
}
}
`
-SEO.propTypes = {
- title: PropTypes.string,
- description: PropTypes.string,
- image: PropTypes.string,
- pathname: PropTypes.string,
- article: PropTypes.bool,
-}
-SEO.defaultProps = {
- title: null,
- description: null,
- image: null,
- pathname: null,
- article: false,
-}
diff --git a/src/images/color.jpg b/src/images/color.jpg
new file mode 100644
index 0000000..8ec7d6e
Binary files /dev/null and b/src/images/color.jpg differ