Remove extra import fixes #24

This commit is contained in:
Kyle Mathews 2017-03-27 10:22:49 -04:00
parent 927626063b
commit 9bbe18709c
2 changed files with 13 additions and 12 deletions

View file

@ -1,8 +1,7 @@
const _ = require('lodash') const _ = require("lodash")
const Promise = require('bluebird') const Promise = require("bluebird")
const path = require('path') const path = require("path")
const select = require(`unist-util-select`) const select = require(`unist-util-select`)
const precache = require(`sw-precache`)
const fs = require(`fs-extra`) const fs = require(`fs-extra`)
exports.createPages = ({ args }) => { exports.createPages = ({ args }) => {
@ -10,8 +9,9 @@ exports.createPages = ({ args }) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const pages = [] const pages = []
const blogPost = path.resolve('templates/template-blog-post.js') const blogPost = path.resolve("templates/template-blog-post.js")
graphql(` graphql(
`
{ {
allMarkdownRemark(limit: 1000) { allMarkdownRemark(limit: 1000) {
edges { edges {
@ -21,15 +21,15 @@ exports.createPages = ({ args }) => {
} }
} }
} }
`) `
.then((result) => { ).then(result => {
if (result.errors) { if (result.errors) {
console.log(result.errors) console.log(result.errors)
reject(result.errors) reject(result.errors)
} }
// Create blog posts pages. // Create blog posts pages.
_.each(result.data.allMarkdownRemark.edges, (edge) => { _.each(result.data.allMarkdownRemark.edges, edge => {
pages.push({ pages.push({
path: edge.node.slug, // required path: edge.node.slug, // required
component: blogPost, component: blogPost,
@ -47,8 +47,8 @@ exports.createPages = ({ args }) => {
// Add custom url pathname for blog posts. // Add custom url pathname for blog posts.
exports.modifyAST = ({ args }) => { exports.modifyAST = ({ args }) => {
const { ast } = args const { ast } = args
const files = select(ast, 'File') const files = select(ast, "File")
files.forEach((file) => { files.forEach(file => {
if (file.extension !== `md`) { if (file.extension !== `md`) {
return return
} }

View file

@ -56,6 +56,7 @@
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"develop": "gatsby develop", "develop": "gatsby develop",
"build": "gatsby build", "build": "gatsby build",
"deploy": "gatsby build --prefix-links && gh-pages -d public" "deploy": "gatsby build --prefix-links && gh-pages -d public",
"fix-semi": "eslint --quiet --ignore-pattern node_modules --ignore-pattern public --parser babel-eslint --no-eslintrc --rule '{\"semi\": [2, \"never\"], \"no-extra-semi\": [2]}' --fix gatsby-node.js"
} }
} }