From 45ab23ff25c1d2b7b0d3dd412b1cf7297372b08b Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Sat, 20 Jan 2018 17:48:39 -0800 Subject: [PATCH 01/11] Upgrade to Gatsby v2 --- gatsby-config.js | 2 +- gatsby-node.js | 14 +- package.json | 33 +- src/components/ReadNext.js | 71 +- src/html.jsx | 64 +- src/layouts/index.js | 4 +- src/pages/index.js | 8 +- src/pages/tags.js | 4 +- src/templates/blog-post.js | 10 +- src/templates/tag-page.js | 12 +- yarn.lock | 6504 ++++++++++++++++++++++-------------- 11 files changed, 4035 insertions(+), 2691 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 98da645f..c42e14f5 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -61,7 +61,7 @@ module.exports = { }, }, `gatsby-plugin-offline`, - `gatsby-plugin-preact`, + // `gatsby-plugin-preact`, `gatsby-plugin-react-helmet`, ], } diff --git a/gatsby-node.js b/gatsby-node.js index 1235fb20..4af9f325 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -3,7 +3,7 @@ const Promise = require("bluebird") const path = require("path") const select = require(`unist-util-select`) const precache = require(`sw-precache`) -const webpackLodashPlugin = require("lodash-webpack-plugin") +const WebpackLodashPlugin = require("lodash-webpack-plugin") exports.createPages = ({ graphql, boundActionCreators }) => { const { createPage } = boundActionCreators @@ -16,8 +16,8 @@ exports.createPages = ({ graphql, boundActionCreators }) => { ` { allMarkdownRemark( - limit: 1000, - filter: { frontmatter: { draft: { ne: true } } }, + limit: 1000 + filter: { frontmatter: { draft: { ne: true } } } ) { edges { node { @@ -104,10 +104,10 @@ exports.onCreateNode = ({ node, boundActionCreators, getNode }) => { } // Add Lodash plugin -exports.modifyWebpackConfig = ({ config, stage }) => { +exports.modifyWebpackConfig = ({ stage, actions }) => { if (stage === `build-javascript`) { - config.plugin(`Lodash`, webpackLodashPlugin, null) + actions.setWebpackConfig({ + plugins: [new WebpackLodashPlugin()], + }) } - - return } diff --git a/package.json b/package.json index e483ddf2..e792aab9 100644 --- a/package.json +++ b/package.json @@ -10,25 +10,26 @@ "babel-plugin-lodash": "^3.2.11", "bluebird": "^3.4.7", "es6-object-assign": "^1.0.3", - "gatsby": "^1.9.22", - "gatsby-link": "^1.6.16", - "gatsby-plugin-google-analytics": "^1.0.7", - "gatsby-plugin-manifest": "^1.0.7", - "gatsby-plugin-offline": "^1.0.9", - "gatsby-plugin-preact": "^1.0.6", - "gatsby-plugin-react-helmet": "^1.0.6", - "gatsby-plugin-sharp": "^1.6.6", - "gatsby-remark-copy-linked-files": "^1.5.7", - "gatsby-remark-images": "^1.5.10", - "gatsby-remark-prismjs": "^1.2.7", - "gatsby-remark-responsive-iframe": "^1.4.7", - "gatsby-remark-smartypants": "^1.4.7", - "gatsby-source-filesystem": "^1.4.12", - "gatsby-transformer-remark": "^1.7.6", - "gatsby-transformer-sharp": "^1.6.5", + "gatsby": "canary", + "gatsby-link": "canary", + "gatsby-plugin-google-analytics": "canary", + "gatsby-plugin-manifest": "canary", + "gatsby-plugin-offline": "canary", + "gatsby-plugin-preact": "canary", + "gatsby-plugin-react-helmet": "canary", + "gatsby-plugin-sharp": "canary", + "gatsby-remark-copy-linked-files": "canary", + "gatsby-remark-images": "canary", + "gatsby-remark-prismjs": "canary", + "gatsby-remark-responsive-iframe": "canary", + "gatsby-remark-smartypants": "canary", + "gatsby-source-filesystem": "canary", + "gatsby-transformer-remark": "canary", + "gatsby-transformer-sharp": "canary", "lodash": "^4.17.4", "lodash-webpack-plugin": "^0.11.2", "prettier": "^1.6.1", + "react-helmet": "^5.2.0", "react-typography": "^0.16.1", "typeface-alegreya": "^0.0.35", "typeface-alegreya-sans": "^0.0.35", diff --git a/src/components/ReadNext.js b/src/components/ReadNext.js index cfe5d135..27af2d52 100644 --- a/src/components/ReadNext.js +++ b/src/components/ReadNext.js @@ -3,46 +3,39 @@ const Link = require("gatsby-link") const { rhythm, scale } = require("../utils/typography") -const Component = React.createClass({ - render() { - //console.log(this.props) - let { nextPost } = this.props - if (nextPost && nextPost.children && nextPost.children[0]) { - nextPost = nextPost.children[0] - } +const Component = props => { + let { nextPost } = props + if (nextPost && nextPost.children && nextPost.children[0]) { + nextPost = nextPost.children[0] + } - if (!nextPost) { - return null - } else { - return ( -
-
- READ THIS NEXT: -
-

- - {nextPost.frontmatter.title} - -

-

- {nextPost.excerpt} -

-
-
- ) - } - }, -}) + if (!nextPost) { + return null + } else { + return ( +
+
+ READ THIS NEXT: +
+

+ {nextPost.frontmatter.title} +

+

{nextPost.excerpt}

+
+
+ ) + } +} export default Component diff --git a/src/html.jsx b/src/html.jsx index 804e21df..cf5e150b 100644 --- a/src/html.jsx +++ b/src/html.jsx @@ -13,40 +13,32 @@ if (process.env.NODE_ENV === `production`) { } } -module.exports = React.createClass({ - render() { - let css - if (process.env.NODE_ENV === `production`) { - css = ( -