From bad4b4be7385252c2abe4ea94e38dbb29c3a329e Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Wed, 2 Jan 2019 18:51:23 -0500 Subject: [PATCH] Adding react-helmet and starting on a Layout component --- gatsby-config.js | 5 +++++ package.json | 4 +++- src/components/Layout/index.js | 20 ++++++++++++++++++++ src/pages/index.js | 6 +++++- yarn.lock | 34 ++++++++++++++++++++++++++++++++-- 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 gatsby-config.js create mode 100644 src/components/Layout/index.js diff --git a/gatsby-config.js b/gatsby-config.js new file mode 100644 index 0000000..af28bc1 --- /dev/null +++ b/gatsby-config.js @@ -0,0 +1,5 @@ +module.exports = { + plugins: [ + 'gatsby-plugin-react-helmet' + ] +}; diff --git a/package.json b/package.json index 125fc1a..230a258 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,10 @@ "eslint-plugin-import": "^2.14.0", "eslint-plugin-react": "^7.12.1", "gatsby": "^2.0.81", + "gatsby-plugin-react-helmet": "^3.0.5", "prop-types": "^15.6.2", "react": "^16.7.0", - "react-dom": "^16.7.0" + "react-dom": "^16.7.0", + "react-helmet": "^5.2.0" } } diff --git a/src/components/Layout/index.js b/src/components/Layout/index.js new file mode 100644 index 0000000..3c22f4f --- /dev/null +++ b/src/components/Layout/index.js @@ -0,0 +1,20 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Helmet } from 'react-helmet'; + +const Layout = ({ title, children }) => + + { title ? `Regexper - ${ title }` : 'Regexper' } + + { children } +; + +Layout.propTypes = { + title: PropTypes.string, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node + ]).isRequired +}; + +export default Layout; diff --git a/src/pages/index.js b/src/pages/index.js index bc93939..8dc0a21 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,5 +1,9 @@ import React from 'react'; -const IndexPage = () =>
Hello world
; +import Layout from 'components/Layout'; + +const IndexPage = () => +
Hello world
+
; export default IndexPage; diff --git a/yarn.lock b/yarn.lock index deb7ac8..afb7b06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4047,6 +4047,11 @@ execa@^1.0.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +exenv@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/exenv/-/exenv-1.2.2.tgz#2ae78e85d9894158670b03d47bec1f03bd91bb9d" + integrity sha1-KueOhdmJQVhnCwPUe+wfA72Ru50= + expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -4594,6 +4599,13 @@ gatsby-plugin-page-creator@^2.0.5: parse-filepath "^1.0.1" slash "^1.0.0" +gatsby-plugin-react-helmet@^3.0.5: + version "3.0.5" + resolved "https://registry.yarnpkg.com/gatsby-plugin-react-helmet/-/gatsby-plugin-react-helmet-3.0.5.tgz#eaeca7c83c6c273d31454598949dd0d3b4ff5f31" + integrity sha512-Xn8d4EckfUkO3xB8qfjn1AcqeA2fYgd6Mbin3RHc/Zu6YRiOQqdJAVBXz+7PbFpTt+6GCluKklEpFUA4RS4oYw== + dependencies: + "@babel/runtime" "^7.0.0" + gatsby-react-router-scroll@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/gatsby-react-router-scroll/-/gatsby-react-router-scroll-2.0.2.tgz#d8046ce2f3bfa52ef6ec55804007d976b0bb6bef" @@ -7741,7 +7753,7 @@ promise@^7.1.1: dependencies: asap "~2.0.3" -prop-types@^15.6.1, prop-types@^15.6.2: +prop-types@^15.5.4, prop-types@^15.6.1, prop-types@^15.6.2: version "15.6.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102" integrity sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ== @@ -7942,6 +7954,16 @@ react-error-overlay@^3.0.0: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-3.0.0.tgz#c2bc8f4d91f1375b3dad6d75265d51cd5eeaf655" integrity sha512-XzgvowFrwDo6TWcpJ/WTiarb9UI6lhA4PMzS7n1joK3sHfBBBOQHUc0U4u57D6DWO9vHv6lVSWx2Q/Ymfyv4hw== +react-helmet@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.0.tgz#a81811df21313a6d55c5f058c4aeba5d6f3d97a7" + integrity sha1-qBgR3yExOm1VxfBYxK66XW89l6c= + dependencies: + deep-equal "^1.0.1" + object-assign "^4.1.1" + prop-types "^15.5.4" + react-side-effect "^1.1.0" + react-hot-loader@^4.6.2: version "4.6.3" resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.6.3.tgz#d9c8923c45b35fd51538ba4297081a00be6bccb1" @@ -7962,6 +7984,14 @@ react-lifecycles-compat@^3.0.4: resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA== +react-side-effect@^1.1.0: + version "1.1.5" + resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-1.1.5.tgz#f26059e50ed9c626d91d661b9f3c8bb38cd0ff2d" + integrity sha512-Z2ZJE4p/jIfvUpiUMRydEVpQRf2f8GMHczT6qLcARmX7QRb28JDBTpnM2g/i5y/p7ZDEXYGHWg0RbhikE+hJRw== + dependencies: + exenv "^1.2.1" + shallowequal "^1.0.1" + react@^16.7.0: version "16.7.0" resolved "https://registry.yarnpkg.com/react/-/react-16.7.0.tgz#b674ec396b0a5715873b350446f7ea0802ab6381" @@ -8575,7 +8605,7 @@ shallow-compare@^1.2.2: resolved "https://registry.yarnpkg.com/shallow-compare/-/shallow-compare-1.2.2.tgz#fa4794627bf455a47c4f56881d8a6132d581ffdb" integrity sha512-LUMFi+RppPlrHzbqmFnINTrazo0lPNwhcgzuAXVVcfy/mqPDrQmHAyz5bvV0gDAuRFrk804V0HpQ6u9sZ0tBeg== -shallowequal@^1.0.2: +shallowequal@^1.0.1, shallowequal@^1.0.2: version "1.1.0" resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8" integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==