From 22dc8652238c47d6ee38c5474d756cdfbe683488 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 13 Jun 2018 20:46:36 +0200 Subject: [PATCH] follow migration guide * https://github.com/gatsbyjs/gatsby/blob/v2/docs/docs/migrating-from-v1-to-v2.md --- gatsby-node.js | 20 +-- package.json | 10 +- src/components/Layout.jsx | 124 ++++++++++++++++++ .../index.scss => components/Layout.scss} | 0 src/components/atoms/ProjectImage.jsx | 4 +- src/components/molecules/ProjectNav.jsx | 2 +- src/layouts/index.jsx | 118 ----------------- src/pages/404.jsx | 31 +++-- src/pages/index.jsx | 29 ++-- src/templates/Project.jsx | 12 +- 10 files changed, 176 insertions(+), 174 deletions(-) create mode 100644 src/components/Layout.jsx rename src/{layouts/index.scss => components/Layout.scss} (100%) delete mode 100644 src/layouts/index.jsx diff --git a/gatsby-node.js b/gatsby-node.js index fc970b3..86b64c1 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,19 +1,7 @@ const path = require('path') -// Intersection Observer polyfill -// requires `npm install intersection-observer` -// https://github.com/gatsbyjs/gatsby/issues/2288#issuecomment-334467821 -exports.modifyWebpackConfig = ({ config, stage }) => { - if (stage === 'build-html') { - config.loader('null', { - test: /intersection-observer/, - loader: 'null-loader' - }) - } -} - -exports.createPages = ({ boundActionCreators, graphql }) => { - const { createPage } = boundActionCreators +exports.createPages = ({ actions, graphql }) => { + const { createPage } = actions return new Promise((resolve, reject) => { const template = path.resolve('src/templates/Project.jsx') @@ -32,7 +20,7 @@ exports.createPages = ({ boundActionCreators, graphql }) => { img { id childImageSharp { - sizes(maxWidth: 500, quality: 80) { + fluid(maxWidth: 500, quality: 80) { aspectRatio src srcSet @@ -51,7 +39,7 @@ exports.createPages = ({ boundActionCreators, graphql }) => { img { id childImageSharp { - sizes(maxWidth: 500, quality: 80) { + fluid(maxWidth: 500, quality: 80) { aspectRatio src srcSet diff --git a/package.json b/package.json index 72c8ca0..ea2f4ff 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "dependencies": { "camel-case": "^3.0.0", "file-saver": "^1.3.8", - "gatsby": "^1.9.270", - "gatsby-image": "^1.0.52", + "gatsby": "next", + "gatsby-image": "next", "gatsby-link": "^1.6.44", "gatsby-plugin-favicon": "^2.1.1", "gatsby-plugin-matomo": "^0.4.0", @@ -30,7 +30,7 @@ "gatsby-plugin-react-helmet": "^2.0.11", "gatsby-plugin-react-next": "^1.0.11", "gatsby-plugin-sass": "^1.0.26", - "gatsby-plugin-sharp": "^1.6.47", + "gatsby-plugin-sharp": "next", "gatsby-plugin-sitemap": "^1.2.25", "gatsby-plugin-svgr": "^1.0.1", "gatsby-source-filesystem": "^1.5.38", @@ -39,6 +39,8 @@ "giphy-js-sdk-core": "^1.0.3", "intersection-observer": "^0.5.0", "js-yaml": "^3.12.0", + "react": "^16.4.1", + "react-dom": "^16.4.1", "react-helmet": "^5.2.0", "react-markdown": "^3.3.2", "react-transition-group": "^2.3.1", @@ -55,7 +57,7 @@ "gatsby-transformer-json": "^1.0.19", "ora": "^2.1.0", "prepend": "^1.0.2", - "prettier": "^1.13.4", + "prettier": "^1.13.5", "prettier-stylelint": "^0.4.2", "slugify": "^1.3.0", "stylelint": "^9.2.1", diff --git a/src/components/Layout.jsx b/src/components/Layout.jsx new file mode 100644 index 0000000..ab43b92 --- /dev/null +++ b/src/components/Layout.jsx @@ -0,0 +1,124 @@ +import React, { Component, Fragment } from 'react' +import PropTypes from 'prop-types' +import withRouter from 'react-router-dom/withRouter' +import TransitionGroup from 'react-transition-group/TransitionGroup' +import Head from './atoms/Head' +import Header from './organisms/Header' +import Footer from './organisms/Footer' +import { FadeIn } from './atoms/Animations' +import './Layout.scss' + +class TransitionHandler extends Component { + shouldComponentUpdate() { + return this.props.location.pathname === window.location.pathname + } + + render() { + const { children } = this.props + return
{children}
+ } +} + +const Main = ({ children }) =>
{children}
+ +const TemplateWrapper = ({ children, location }) => { + const isHomepage = location.pathname === '/' + + return ( + { + const meta = data.dataYaml + const pkg = data.portfolioJson + + return ( + + +
+ + + + + {children} + + + + +