Skip to content

Commit

Permalink
Prettier formats gatsby-node file as well (#10918)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Sep 28, 2017
1 parent fb77b3d commit b2ae4b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion scripts/prettier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const defaultOptions = {
const config = {
default: {
patterns: ['src/**/*.js', 'www/**/*.js'],
ignore: ['**/third_party/**', '**/node_modules/**', 'www/gatsby-node.js'],
ignore: ['**/third_party/**', '**/node_modules/**'],
},
scripts: {
patterns: ['scripts/**/*.js', 'fixtures/**/*.js'],
Expand Down
29 changes: 14 additions & 15 deletions www/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
const {resolve} = require('path');
const webpack = require('webpack');

exports.modifyWebpackConfig = ({ config, stage }) => {
exports.modifyWebpackConfig = ({config, stage}) => {
// See https://github.com/FormidableLabs/react-live/issues/5
config.plugin('ignore', () => new webpack.IgnorePlugin(/^(xor|props)$/));

Expand All @@ -35,7 +35,8 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
const homeTemplate = resolve('./src/templates/home.js');
const installationTemplate = resolve('./src/templates/installation.js');

const allMarkdown = await graphql(`
const allMarkdown = await graphql(
`
{
allMarkdownRemark(limit: 1000) {
edges {
Expand All @@ -48,7 +49,8 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
}
}
}
`);
`,
);

if (allMarkdown.errors) {
console.error(allMarkdown.errors);
Expand All @@ -75,11 +77,9 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
slug,
},
});

} else if (slug === 'docs/error-decoder.html') {
// No-op so far as markdown templates go.
// Error codes are managed by a page (which gets created automatically).

} else if (
slug.includes('blog/') ||
slug.includes('community/') ||
Expand All @@ -92,10 +92,7 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
template = blogTemplate;
} else if (slug.includes('community/')) {
template = communityTemplate;
} else if (
slug.includes('contributing/') ||
slug.includes('docs/')
) {
} else if (slug.includes('contributing/') || slug.includes('docs/')) {
template = docsTemplate;
} else if (slug.includes('tutorial/')) {
template = tutorialTemplate;
Expand Down Expand Up @@ -125,13 +122,14 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
fromPath: `/${fromPath}`,
redirectInBrowser: true,
toPath: `/${slug}`,
})
}),
);
}
}
});

const newestBlogEntry = await graphql(`
const newestBlogEntry = await graphql(
`
{
allMarkdownRemark(
limit: 1,
Expand All @@ -147,7 +145,8 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
}
}
}
`);
`,
);
const newestBlogNode = newestBlogEntry.data.allMarkdownRemark.edges[0].node;

// Blog landing page should always show the most recent blog entry.
Expand Down Expand Up @@ -202,7 +201,7 @@ exports.onCreateNode = ({node, boundActionCreators, getNode}) => {
// This should (probably) only happen for the index.md,
// But let's log it in case it happens for other files also.
console.warn(
`Warning: No slug found for "${relativePath}". Falling back to default "${slug}".`
`Warning: No slug found for "${relativePath}". Falling back to default "${slug}".`,
);
}

Expand Down Expand Up @@ -230,8 +229,8 @@ exports.onCreateNode = ({node, boundActionCreators, getNode}) => {
}
};

exports.onCreatePage = async ({ page, boundActionCreators }) => {
const { createPage } = boundActionCreators;
exports.onCreatePage = async ({page, boundActionCreators}) => {
const {createPage} = boundActionCreators;

return new Promise(resolvePromise => {
// page.matchPath is a special key that's used for matching pages only on the client.
Expand Down

0 comments on commit b2ae4b8

Please sign in to comment.