From ca348a35342b2e0b421ebf740f73a1b375be8f4c Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 22 Jun 2018 18:54:29 +0200 Subject: [PATCH] refactor project nav --- package.json | 2 +- src/components/molecules/ProjectNav.jsx | 76 ++++++++++++++++++------- src/pages/404.jsx | 2 +- src/templates/Project.jsx | 24 +------- 4 files changed, 59 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 38c4b23..af43334 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "file-saver": "^1.3.8", - "gatsby": "^2.0.0-beta.6", + "gatsby": "^2.0.0-beta.9", "gatsby-image": "^2.0.0-beta.2", "gatsby-plugin-favicon": "^2.1.1", "gatsby-plugin-matomo": "^0.4.0", diff --git a/src/components/molecules/ProjectNav.jsx b/src/components/molecules/ProjectNav.jsx index a81fedf..12f3567 100644 --- a/src/components/molecules/ProjectNav.jsx +++ b/src/components/molecules/ProjectNav.jsx @@ -1,6 +1,6 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' -import { Link } from 'gatsby' +import { Link, graphql, StaticQuery } from 'gatsby' import Img from 'gatsby-image' import styles from './ProjectNav.module.scss' @@ -15,6 +15,31 @@ const ProjectLink = ({ node }) => ( ) +const ProjectNavQuery = ({ render }) => ( + +) + class ProjectNav extends Component { constructor(props) { super(props) @@ -40,31 +65,39 @@ class ProjectNav extends Component { } render() { - const { projects, project } = this.props + const { slug } = this.props return ( - ) - })} - + }} + /> ) } } @@ -74,8 +107,11 @@ ProjectLink.propTypes = { } ProjectNav.propTypes = { - projects: PropTypes.array, - project: PropTypes.object + slug: PropTypes.string +} + +ProjectNavQuery.propTypes = { + render: PropTypes.any } export default ProjectNav diff --git a/src/pages/404.jsx b/src/pages/404.jsx index f72fe39..1f622be 100644 --- a/src/pages/404.jsx +++ b/src/pages/404.jsx @@ -1,5 +1,5 @@ import React, { Component } from 'react' -import Link from 'gatsby' +import { Link } from 'gatsby' import giphyAPI from 'giphy-js-sdk-core' import Layout from '../components/Layout' import Content from '../components/atoms/Content' diff --git a/src/templates/Project.jsx b/src/templates/Project.jsx index 2dec3c3..a54d8e1 100644 --- a/src/templates/Project.jsx +++ b/src/templates/Project.jsx @@ -45,7 +45,6 @@ class Project extends Component { render() { const meta = this.props.data.dataYaml - const projects = this.props.data.allProjectsYaml.edges const project = this.props.data.projectsYaml const projectImages = this.props.data.projectImages.edges const { title, links, techstack } = project @@ -68,7 +67,7 @@ class Project extends Component { - + ) } @@ -123,11 +122,6 @@ export const projectAndProjectsQuery = graphql` GitHub Dribbble } - availability { - status - available - unavailable - } img { childImageSharp { resize(width: 980) { @@ -148,21 +142,5 @@ export const projectAndProjectsQuery = graphql` } } } - - allProjectsYaml { - edges { - node { - title - slug - img { - childImageSharp { - fluid(maxWidth: 500, quality: 85) { - ...GatsbyImageSharpFluid_noBase64 - } - } - } - } - } - } } `