diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..1e9ad3b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,19 @@ +{ + "plugins": ["react", "graphql"], + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "jsx": true, + "modules": true + } + }, + "env": { + "browser": true, + "node": true + }, + "extends": ["eslint:recommended", "plugin:react/recommended"], + "rules": { + "quotes": ["error", "single"], + "semi": ["error", "never"] + } +} diff --git a/src/data/meta.json b/data/meta.json similarity index 100% rename from src/data/meta.json rename to data/meta.json diff --git a/src/data/projects.json b/data/projects.json similarity index 100% rename from src/data/projects.json rename to data/projects.json diff --git a/gatsby-config.js b/gatsby-config.js index 53d33fd..643d7a1 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -4,12 +4,20 @@ module.exports = { }, plugins: [ 'gatsby-plugin-react-helmet', + 'gatsby-transformer-json', + { + resolve: 'gatsby-source-filesystem', + options: { + name: 'data', + path: `${__dirname}/data/`, + }, + }, { resolve: 'gatsby-plugin-sass', options: { includePaths: [ - './node_modules', - './src/stylesheets', + `${__dirname}/node_modules`, + `${__dirname}/src/styles`, ], }, }, diff --git a/gatsby-node.js b/gatsby-node.js index 201108c..99f1e2e 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,7 +1,52 @@ -/** - * Implement Gatsby's Node APIs in this file. - * - * See: https://www.gatsbyjs.org/docs/node-apis/ - */ +const path = require('path') - // You can delete this file if you're not using it \ No newline at end of file +// Implement the Gatsby API “createPages”. This is called once the +// data layer is bootstrapped to let plugins create pages from data. +exports.createPages = ({ boundActionCreators, graphql }) => { + const { createPage } = boundActionCreators + + return new Promise((resolve, reject) => { + const template = path.resolve('src/layouts/Project.js') + + resolve( + graphql(` + { + allProjectsJson { + edges { + node { + title + slug + img + img_more + links { + Link + GitHub + Info + } + description + techstack + } + } + } + } + `).then(result => { + if (result.errors) { + reject(result.errors) + } + + console.log(result) + + result.data.allProjectsJson.edges.forEach(({ node }) => { + const slug = node.slug + + createPage({ + path: slug, + component: template, + context: { slug: slug }, + }) + }) + + resolve() + })) + }) +} diff --git a/package.json b/package.json index 1222adb..ff2b7f9 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,17 @@ "gatsby-link": "^1.6.39", "gatsby-plugin-react-helmet": "^2.0.8", "gatsby-plugin-sass": "latest", + "gatsby-source-filesystem": "^1.5.28", + "gatsby-transformer-json": "^1.0.16", "react-helmet": "^5.2.0", - "react-markdown": "3.3.0", + "react-markdown": "^3.3.0", "react-transition-group": "^2.3.0" }, "devDependencies": { + "babel-eslint": "^8.2.2", + "eslint": "^4.19.1", + "eslint-plugin-graphql": "^1.5.0", + "eslint-plugin-react": "^7.7.0", "prettier": "^1.11.1" }, "scripts": { diff --git a/src/components/atoms/Content.js b/src/components/atoms/Content.js index 06a9cbc..95a5b24 100644 --- a/src/components/atoms/Content.js +++ b/src/components/atoms/Content.js @@ -1,6 +1,6 @@ import React from 'react' import PropTypes from 'prop-types' -import './Content.css' +import './Content.scss' const Content = ({children}) => (