Browse Source

Updated Prettier tasks to cover gatsby-* JS files in root

main
Brian Vaughn 7 years ago
parent
commit
f11badf8a6
  1. 49
      gatsby-node.js
  2. 4
      package.json

49
gatsby-node.js

@ -36,19 +36,19 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
const allMarkdown = await graphql( const allMarkdown = await graphql(
` `
{ {
allMarkdownRemark(limit: 1000) { allMarkdownRemark(limit: 1000) {
edges { edges {
node { node {
fields { fields {
redirect redirect
slug slug
}
} }
} }
} }
} }
} `,
`,
); );
if (allMarkdown.errors) { if (allMarkdown.errors) {
@ -116,9 +116,10 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
redirect.forEach(fromPath => { redirect.forEach(fromPath => {
if (redirectToSlugMap[fromPath] != null) { if (redirectToSlugMap[fromPath] != null) {
console.error(`Duplicate redirect detected from "${fromPath}" to:\n` + console.error(
`* ${redirectToSlugMap[fromPath]}\n` + `Duplicate redirect detected from "${fromPath}" to:\n` +
`* ${slug}\n` `* ${redirectToSlugMap[fromPath]}\n` +
`* ${slug}\n`,
); );
process.exit(1); process.exit(1);
} }
@ -136,22 +137,22 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
const newestBlogEntry = await graphql( const newestBlogEntry = await graphql(
` `
{ {
allMarkdownRemark( allMarkdownRemark(
limit: 1, limit: 1
filter: { id: { regex: "/blog/" } } filter: {id: {regex: "/blog/"}}
sort: { fields: [fields___date], order: DESC } sort: {fields: [fields___date], order: DESC}
) { ) {
edges { edges {
node { node {
fields { fields {
slug slug
}
} }
} }
} }
} }
} `,
`,
); );
const newestBlogNode = newestBlogEntry.data.allMarkdownRemark.edges[0].node; const newestBlogNode = newestBlogEntry.data.allMarkdownRemark.edges[0].node;

4
package.json

@ -77,8 +77,8 @@
"dev": "gatsby develop -H 0.0.0.0", "dev": "gatsby develop -H 0.0.0.0",
"lint": "eslint .", "lint": "eslint .",
"netlify": "yarn install && yarn build", "netlify": "yarn install && yarn build",
"prettier": "prettier --config .prettierrc --write \"{flow-typed,plugins,src}/**/*.js\"", "prettier": "prettier --config .prettierrc --write \"{gatsby-*.js,{flow-typed,plugins,src}/**/*.js}\"",
"prettier:diff": "prettier --config .prettierrc --list-different \"{flow-typed,plugins,src}/**/*.js\"", "prettier:diff": "prettier --config .prettierrc --list-different \"{gatsby-*.js,{flow-typed,plugins,src}/**/*.js}\"",
"reset": "rimraf ./.cache" "reset": "rimraf ./.cache"
}, },
"devDependencies": { "devDependencies": {

Loading…
Cancel
Save