From f31db82d437bf77df494ba1810c0961546b77e47 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Wed, 10 Jan 2018 06:16:51 -0800 Subject: [PATCH] Format --- examples/using-faker/src/pages/index.js | 56 ++-- .../src/pages/2017-11-14---excerpts/index.md | 24 +- .../example---custom-separator/index.md | 10 +- .../examples/example---no-separator/index.md | 17 +- .../using-remark/src/pages/excerpt-example.js | 13 +- examples/using-remark/src/pages/index.js | 7 +- examples/using-remark/src/pages/tags.js | 7 +- .../src/__tests__/extend-node.js | 138 ++++---- .../src/__tests__/gatsby-node.js | 298 +++++++++--------- .../src/on-node-create.js | 10 +- packages/gatsby/src/commands/develop.js | 6 +- 11 files changed, 293 insertions(+), 293 deletions(-) diff --git a/examples/using-faker/src/pages/index.js b/examples/using-faker/src/pages/index.js index 054cebbcec675..b17e235d09091 100644 --- a/examples/using-faker/src/pages/index.js +++ b/examples/using-faker/src/pages/index.js @@ -3,38 +3,38 @@ import Link from "gatsby-link" import "./index.css" const IndexPage = ({ data }) => ( -
-
-
-

Address

-
{data.personalData.address.streetAddress}
-
{data.personalData.address.streetName}
-
{data.personalData.address.city}
-
- {data.personalData.address.state} - - {data.personalData.address.zipCode} -
-
-
- {data.personalData.internet.email} / - {data.personalData.phone.phoneNumber} -
-
-

Summary

- {data.personalData.lorem.paragraph} +
+
+
+

Address

+
{data.personalData.address.streetAddress}
+
{data.personalData.address.streetName}
+
{data.personalData.address.city}
+
+ {data.personalData.address.state} - + {data.personalData.address.zipCode}
-
-

Worked at

- {data.allCompanyData.edges.map(({ node }) => ( -
-
{node.company.companyName}
-
{node.company.companySuffix}
-
- ))} +
+ {data.personalData.internet.email} / + {data.personalData.phone.phoneNumber} +
+
+

Summary

+ {data.personalData.lorem.paragraph}
- ) +
+

Worked at

+ {data.allCompanyData.edges.map(({ node }) => ( +
+
{node.company.companyName}
+
{node.company.companySuffix}
+
+ ))} +
+
+) export default IndexPage diff --git a/examples/using-remark/src/pages/2017-11-14---excerpts/index.md b/examples/using-remark/src/pages/2017-11-14---excerpts/index.md index 612d1c497717a..303611c28b35f 100644 --- a/examples/using-remark/src/pages/2017-11-14---excerpts/index.md +++ b/examples/using-remark/src/pages/2017-11-14---excerpts/index.md @@ -12,13 +12,13 @@ tags: ```graphql { - allMarkdownRemark { - edges { - node { - excerpt(pruneLength:280) - } - } - } + allMarkdownRemark { + edges { + node { + excerpt(pruneLength: 280) + } + } + } } ``` @@ -26,13 +26,13 @@ You can also manually mark in your markdown where to stop excerpting—similar t ```json { - resolve: `gatsby-transformer-remark`, - options: { - excerpt_separator: `` - } + resolve: `gatsby-transformer-remark`, + options: { + excerpt_separator: `` + } } ``` Any file that does not have the given excerpt_separator will fall back to the default pruning method. -You can see the results [here](/excerpt-example) \ No newline at end of file +You can see the results [here](/excerpt-example) diff --git a/examples/using-remark/src/pages/examples/example---custom-separator/index.md b/examples/using-remark/src/pages/examples/example---custom-separator/index.md index 3f08db009805c..08d0c31926a7f 100644 --- a/examples/using-remark/src/pages/examples/example---custom-separator/index.md +++ b/examples/using-remark/src/pages/examples/example---custom-separator/index.md @@ -13,11 +13,11 @@ You can manually mark in your markdown where to stop excerpting—similar to Jek ```json { - resolve: `gatsby-transformer-remark`, - options: { - excerpt_separator: `` - } + resolve: `gatsby-transformer-remark`, + options: { + excerpt_separator: `` + } } ``` -Any file that does not have the given excerpt_separator will fall back to the default pruning method. \ No newline at end of file +Any file that does not have the given excerpt_separator will fall back to the default pruning method. diff --git a/examples/using-remark/src/pages/examples/example---no-separator/index.md b/examples/using-remark/src/pages/examples/example---no-separator/index.md index 67f7ce05ec252..1839c21db2a1f 100644 --- a/examples/using-remark/src/pages/examples/example---no-separator/index.md +++ b/examples/using-remark/src/pages/examples/example---no-separator/index.md @@ -4,18 +4,19 @@ draft: false example: true author: Daisy Buchanan --- + This example uses the default pruning method. `gatsby-transformer-remark` allows you to get an excerpt from a markdown post. By default, it will prune the first 140 characters, but you can optionally specify a `pruneLength` in the graphql query. ```graphql { - allMarkdownRemark { - edges { - node { - excerpt(pruneLength:280) - } - } - } + allMarkdownRemark { + edges { + node { + excerpt(pruneLength: 280) + } + } + } } -``` \ No newline at end of file +``` diff --git a/examples/using-remark/src/pages/excerpt-example.js b/examples/using-remark/src/pages/excerpt-example.js index 9893c71b70f70..71b493bc68eb5 100644 --- a/examples/using-remark/src/pages/excerpt-example.js +++ b/examples/using-remark/src/pages/excerpt-example.js @@ -18,7 +18,8 @@ class Index extends React.Component { marginBottom: rhythm(2), }} > - This page demonstrates the different types of excerpts you can use with gatsby-transformer-remark + This page demonstrates the different types of excerpts you can use + with gatsby-transformer-remark
    {post.node.frontmatter.title} -

    - {post.node.excerpt} -

    +

    {post.node.excerpt}

    ))}
@@ -61,9 +60,7 @@ export default Index export const pageQuery = graphql` query ExcerptExampleQuery { - allMarkdownRemark( - filter: { frontmatter: { example: { eq: true } } } - ) { + allMarkdownRemark(filter: { frontmatter: { example: { eq: true } } }) { edges { node { fields { @@ -77,4 +74,4 @@ export const pageQuery = graphql` } } } -` \ No newline at end of file +` diff --git a/examples/using-remark/src/pages/index.js b/examples/using-remark/src/pages/index.js index b3b02bb1cbd11..8ca6576f160ea 100644 --- a/examples/using-remark/src/pages/index.js +++ b/examples/using-remark/src/pages/index.js @@ -75,12 +75,7 @@ export const pageQuery = graphql` allMarkdownRemark( limit: 2000 sort: { fields: [frontmatter___date], order: DESC } - filter: { - frontmatter: { - draft: { ne: true } - example: { ne: true } - } - } + filter: { frontmatter: { draft: { ne: true }, example: { ne: true } } } ) { edges { node { diff --git a/examples/using-remark/src/pages/tags.js b/examples/using-remark/src/pages/tags.js index e4d2be55c02ed..d9b3cabee43b1 100644 --- a/examples/using-remark/src/pages/tags.js +++ b/examples/using-remark/src/pages/tags.js @@ -39,12 +39,7 @@ export const pageQuery = graphql` } allMarkdownRemark( limit: 2000 - filter: { - frontmatter: { - draft: { ne: true } - example: { ne: true } - } - } + filter: { frontmatter: { draft: { ne: true }, example: { ne: true } } } ) { group(field: frontmatter___tags) { fieldValue diff --git a/packages/gatsby-transformer-remark/src/__tests__/extend-node.js b/packages/gatsby-transformer-remark/src/__tests__/extend-node.js index e065ded28bffc..3a6c2749db0f2 100644 --- a/packages/gatsby-transformer-remark/src/__tests__/extend-node.js +++ b/packages/gatsby-transformer-remark/src/__tests__/extend-node.js @@ -1,100 +1,100 @@ const _ = require(`lodash`) const { - graphql, - GraphQLObjectType, - GraphQLList, - GraphQLSchema, - } = require(`graphql`) + graphql, + GraphQLObjectType, + GraphQLList, + GraphQLSchema, +} = require(`graphql`) const { onCreateNode } = require(`../gatsby-node`) -const { inferObjectStructureFromNodes } = require(`../../../gatsby/src/schema/infer-graphql-type`) +const { + inferObjectStructureFromNodes, +} = require(`../../../gatsby/src/schema/infer-graphql-type`) // given a set of nodes and a query, return the result of the query async function queryResult(nodes, fragment, { types = [] } = {}) { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: `RootQueryType`, - fields: () => { - return { - listNode: { - name: `LISTNODE`, - type: new GraphQLList( - new GraphQLObjectType({ - name: `MarkdownRemark`, - fields: inferObjectStructureFromNodes({ - nodes, - types: [...types], - }), - }) - ), - resolve() { - return nodes - }, - }, - } + const schema = new GraphQLSchema({ + query: new GraphQLObjectType({ + name: `RootQueryType`, + fields: () => { + return { + listNode: { + name: `LISTNODE`, + type: new GraphQLList( + new GraphQLObjectType({ + name: `MarkdownRemark`, + fields: inferObjectStructureFromNodes({ + nodes, + types: [...types], + }), + }) + ), + resolve() { + return nodes }, - }), - }) + }, + } + }, + }), + }) - const result = await graphql( - schema, - `query { + const result = await graphql( + schema, + `query { listNode { ${fragment} } } - `, - ) - return result + ` + ) + return result } describe(`Excerpt is generated correctly from schema`, () => { - - const node = { - id: `whatever`, - children: [], - internal: { - contentDigest: `whatever`, - mediaType: `text/markdown`, - }, - } - - // Make some fake functions its expecting. - const loadNodeContent = node => Promise.resolve(node.content) + const node = { + id: `whatever`, + children: [], + internal: { + contentDigest: `whatever`, + mediaType: `text/markdown`, + }, + } + + // Make some fake functions its expecting. + const loadNodeContent = node => Promise.resolve(node.content) - - it(`correctly loads a default excerpt`, async () => { - const content = `--- + it(`correctly loads a default excerpt`, async () => { + const content = `--- title: "my little pony" date: "2017-09-18T23:19:51.246Z" --- Where oh where is my little pony? ` - node.content = content - - const createNode = markdownNode => { - queryResult([ markdownNode ], - ` + node.content = content + + const createNode = markdownNode => { + queryResult( + [markdownNode], + ` excerpt frontmatter { title } `, - { - types: [ { name: `MarkdownRemark` } ], - }).then(result => { - expect(_.isString(result.data.listNode.excerpt)) - }) + { + types: [{ name: `MarkdownRemark` }], } - const createParentChildLink = jest.fn() - const boundActionCreators = { createNode, createParentChildLink } + ).then(result => { + expect(_.isString(result.data.listNode.excerpt)) + }) + } + const createParentChildLink = jest.fn() + const boundActionCreators = { createNode, createParentChildLink } - await onCreateNode({ - node, - loadNodeContent, - boundActionCreators, - }) + await onCreateNode({ + node, + loadNodeContent, + boundActionCreators, }) - }) - \ No newline at end of file +}) diff --git a/packages/gatsby-transformer-remark/src/__tests__/gatsby-node.js b/packages/gatsby-transformer-remark/src/__tests__/gatsby-node.js index e5f96202592d1..382f8363de967 100644 --- a/packages/gatsby-transformer-remark/src/__tests__/gatsby-node.js +++ b/packages/gatsby-transformer-remark/src/__tests__/gatsby-node.js @@ -4,12 +4,14 @@ const _ = require(`lodash`) const { onCreateNode } = require(`../gatsby-node`) const { - graphql, - GraphQLObjectType, - GraphQLList, - GraphQLSchema, - } = require(`graphql`) -const { inferObjectStructureFromNodes } = require(`../../../gatsby/src/schema/infer-graphql-type`) + graphql, + GraphQLObjectType, + GraphQLList, + GraphQLSchema, +} = require(`graphql`) +const { + inferObjectStructureFromNodes, +} = require(`../../../gatsby/src/schema/infer-graphql-type`) describe(`Process markdown content correctly`, () => { const node = { @@ -24,37 +26,37 @@ describe(`Process markdown content correctly`, () => { // Make some fake functions its expecting. const loadNodeContent = node => Promise.resolve(node.content) - describe(`Process generated markdown node correctly`, () => { - it(`Correctly creates a new MarkdownRemark node`, async () => { - const content = `--- + describe(`Process generated markdown node correctly`, () => { + it(`Correctly creates a new MarkdownRemark node`, async () => { + const content = `--- title: "my little pony" date: "2017-09-18T23:19:51.246Z" --- Where oh where is my little pony? ` - node.content = content - - const createNode = jest.fn() - const createParentChildLink = jest.fn() - const boundActionCreators = { createNode, createParentChildLink } - - await onCreateNode({ - node, - loadNodeContent, - boundActionCreators, - }).then(() => { - expect(createNode.mock.calls).toMatchSnapshot() - expect( - _.isString(createNode.mock.calls[0][0].frontmatter.date) - ).toBeTruthy() - expect(createParentChildLink.mock.calls).toMatchSnapshot() - expect(createNode).toHaveBeenCalledTimes(1) - expect(createParentChildLink).toHaveBeenCalledTimes(1) - }) - }) + node.content = content + + const createNode = jest.fn() + const createParentChildLink = jest.fn() + const boundActionCreators = { createNode, createParentChildLink } + + await onCreateNode({ + node, + loadNodeContent, + boundActionCreators, + }).then(() => { + expect(createNode.mock.calls).toMatchSnapshot() + expect( + _.isString(createNode.mock.calls[0][0].frontmatter.date) + ).toBeTruthy() + expect(createParentChildLink.mock.calls).toMatchSnapshot() + expect(createNode).toHaveBeenCalledTimes(1) + expect(createParentChildLink).toHaveBeenCalledTimes(1) + }) + }) - it(`Correctly parses a graymatter excerpt`, async () => { - const content = `--- + it(`Correctly parses a graymatter excerpt`, async () => { + const content = `--- title: "my little pony" date: "2017-09-18T23:19:51.246Z" --- @@ -69,75 +71,74 @@ Maecenas sodales, arcu at dictum porta, sapien leo consectetur metus, nec rhoncu Sed eu gravida mauris. Suspendisse potenti. Praesent sit amet egestas mi, sed hendrerit eros. Vestibulum congue scelerisque magna, id viverra justo congue nec. Duis id dapibus metus, et dictum erat. Nulla rhoncus a mauris nec tincidunt. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec elementum molestie ullamcorper. Nulla pulvinar feugiat mauris, placerat malesuada ligula rutrum non. Integer venenatis ex at dignissim fermentum. Nunc bibendum nulla in purus pharetra, non sodales justo fringilla. Sed bibendum sem iaculis, pellentesque leo sed, imperdiet ante. Sed consequat mattis dui nec pretium. Donec vel consectetur est. Nam sagittis, libero vitae pretium pharetra, velit est dignissim erat, at cursus quam massa vitae ligula. Suspendisse potenti. In hac habitasse platea dictumst. Donec sit amet finibus justo. Mauris ante dolor, pulvinar vitae feugiat eu, rhoncus nec diam. In ut accumsan diam, faucibus fringilla odio. Nunc id ultricies turpis. Quisque justo quam, tristique sit amet interdum quis, facilisis at mi. Fusce porttitor vel sem ut condimentum. Praesent at libero congue, vulputate elit ut, rhoncus erat. - ` - - node.content = content - - const createNode = jest.fn() - const createParentChildLink = jest.fn() - const boundActionCreators = { createNode, createParentChildLink } - - await onCreateNode({ - node, - loadNodeContent, - boundActionCreators, - }, { excerpt_separator: `` }).then(() => { - expect(createNode.mock.calls).toMatchSnapshot() - expect( - _.isString(createNode.mock.calls[0][0].excerpt) - ).toBeTruthy() - expect(createNode.mock.calls[0][0].excerpt).not.toEqual(0) - expect(createParentChildLink.mock.calls).toMatchSnapshot() - expect(createNode).toHaveBeenCalledTimes(1) - expect(createParentChildLink).toHaveBeenCalledTimes(1) - }) - }) + ` + node.content = content + + const createNode = jest.fn() + const createParentChildLink = jest.fn() + const boundActionCreators = { createNode, createParentChildLink } + + await onCreateNode( + { + node, + loadNodeContent, + boundActionCreators, + }, + { excerpt_separator: `` } + ).then(() => { + expect(createNode.mock.calls).toMatchSnapshot() + expect(_.isString(createNode.mock.calls[0][0].excerpt)).toBeTruthy() + expect(createNode.mock.calls[0][0].excerpt).not.toEqual(0) + expect(createParentChildLink.mock.calls).toMatchSnapshot() + expect(createNode).toHaveBeenCalledTimes(1) + expect(createParentChildLink).toHaveBeenCalledTimes(1) + }) }) - - describe(`process graphql correctly`, () => { - - // given a set of nodes and a query, return the result of the query - async function queryResult(nodes, fragment, { types = [] } = {}) { - const schema = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: `RootQueryType`, - fields: () => { - return { - listNode: { - name: `LISTNODE`, - type: new GraphQLList( - new GraphQLObjectType({ - name: `MarkdownRemark`, - fields: inferObjectStructureFromNodes({ - nodes, - types: [...types], - }), - }) - ), - resolve() { - return nodes - }, - }, - } - }, - }), - }) - - const result = await graphql( - schema, - `query { + }) + + describe(`process graphql correctly`, () => { + // given a set of nodes and a query, return the result of the query + async function queryResult(nodes, fragment, { types = [] } = {}) { + const schema = new GraphQLSchema({ + query: new GraphQLObjectType({ + name: `RootQueryType`, + fields: () => { + return { + listNode: { + name: `LISTNODE`, + type: new GraphQLList( + new GraphQLObjectType({ + name: `MarkdownRemark`, + fields: inferObjectStructureFromNodes({ + nodes, + types: [...types], + }), + }) + ), + resolve() { + return nodes + }, + }, + } + }, + }), + }) + + const result = await graphql( + schema, + `query { listNode { ${fragment} } } - `, - ) - return result - } + ` + ) + return result + } - it(`Correctly queries an excerpt for a node with an excerpt separator`, done => { - const content = `--- + it(`Correctly queries an excerpt for a node with an excerpt separator`, done => { + const content = `--- title: "my little pony" date: "2017-09-18T23:19:51.246Z" --- @@ -152,46 +153,52 @@ Maecenas sodales, arcu at dictum porta, sapien leo consectetur metus, nec rhoncu Sed eu gravida mauris. Suspendisse potenti. Praesent sit amet egestas mi, sed hendrerit eros. Vestibulum congue scelerisque magna, id viverra justo congue nec. Duis id dapibus metus, et dictum erat. Nulla rhoncus a mauris nec tincidunt. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec elementum molestie ullamcorper. Nulla pulvinar feugiat mauris, placerat malesuada ligula rutrum non. Integer venenatis ex at dignissim fermentum. Nunc bibendum nulla in purus pharetra, non sodales justo fringilla. Sed bibendum sem iaculis, pellentesque leo sed, imperdiet ante. Sed consequat mattis dui nec pretium. Donec vel consectetur est. Nam sagittis, libero vitae pretium pharetra, velit est dignissim erat, at cursus quam massa vitae ligula. Suspendisse potenti. In hac habitasse platea dictumst. Donec sit amet finibus justo. Mauris ante dolor, pulvinar vitae feugiat eu, rhoncus nec diam. In ut accumsan diam, faucibus fringilla odio. Nunc id ultricies turpis. Quisque justo quam, tristique sit amet interdum quis, facilisis at mi. Fusce porttitor vel sem ut condimentum. Praesent at libero congue, vulputate elit ut, rhoncus erat. - ` + ` - node.content = content + node.content = content - let createdNode - const createNode = markdownNode => - queryResult([ markdownNode ], - ` + let createdNode + const createNode = markdownNode => + queryResult( + [markdownNode], + ` excerpt frontmatter { title } - `,{ types: [ { name: `MarkdownRemark` } ] }).then(result => { - try { - createdNode = result.data.listNode[0] - expect(createdNode).toMatchSnapshot() - expect(createdNode.excerpt).toMatch(`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi auctor sit amet velit id facilisis. Nulla viverra, eros at efficitur pulvinar, lectus orci accumsan nisi, eu blandit elit nulla nec lectus. Integer porttitor imperdiet sapien. Quisque in orci sed nisi consequat aliquam. Aenean id mollis nisi. Sed auctor odio id erat facilisis venenatis. Quisque posuere faucibus libero vel fringilla. + `, + { types: [{ name: `MarkdownRemark` }] } + ).then(result => { + try { + createdNode = result.data.listNode[0] + expect(createdNode).toMatchSnapshot() + expect(createdNode.excerpt) + .toMatch(`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi auctor sit amet velit id facilisis. Nulla viverra, eros at efficitur pulvinar, lectus orci accumsan nisi, eu blandit elit nulla nec lectus. Integer porttitor imperdiet sapien. Quisque in orci sed nisi consequat aliquam. Aenean id mollis nisi. Sed auctor odio id erat facilisis venenatis. Quisque posuere faucibus libero vel fringilla. In quis lectus sed eros efficitur luctus. Morbi tempor, nisl eget feugiat tincidunt, sem velit vulputate enim, nec interdum augue enim nec mauris. Nulla iaculis ante sed enim placerat pretium. Nulla metus odio, facilisis vestibulum lobortis vitae, bibendum at nunc. Donec sit amet efficitur metus, in bibendum nisi. Vivamus tempus vel turpis sit amet auctor. Maecenas luctus vestibulum velit, at sagittis leo volutpat quis. Praesent posuere nec augue eget sodales. Pellentesque vitae arcu ut est varius venenatis id maximus sem. Curabitur non consectetur turpis. `) - done() - } catch (err) { - done.fail(err) - } - }) - - const createParentChildLink = jest.fn() - const boundActionCreators = { createNode, createParentChildLink } - - onCreateNode({ - node, - loadNodeContent, - boundActionCreators, - }, { excerpt_separator: `` }) + done() + } catch (err) { + done.fail(err) + } }) + const createParentChildLink = jest.fn() + const boundActionCreators = { createNode, createParentChildLink } + + onCreateNode( + { + node, + loadNodeContent, + boundActionCreators, + }, + { excerpt_separator: `` } + ) + }) - it(`Correctly queries an excerpt for a node without an excerpt separator`, done => { - const content = `--- + it(`Correctly queries an excerpt for a node without an excerpt separator`, done => { + const content = `--- title: "my little pony" date: "2017-09-18T23:19:51.246Z" --- @@ -204,37 +211,40 @@ Maecenas sodales, arcu at dictum porta, sapien leo consectetur metus, nec rhoncu Sed eu gravida mauris. Suspendisse potenti. Praesent sit amet egestas mi, sed hendrerit eros. Vestibulum congue scelerisque magna, id viverra justo congue nec. Duis id dapibus metus, et dictum erat. Nulla rhoncus a mauris nec tincidunt. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec elementum molestie ullamcorper. Nulla pulvinar feugiat mauris, placerat malesuada ligula rutrum non. Integer venenatis ex at dignissim fermentum. Nunc bibendum nulla in purus pharetra, non sodales justo fringilla. Sed bibendum sem iaculis, pellentesque leo sed, imperdiet ante. Sed consequat mattis dui nec pretium. Donec vel consectetur est. Nam sagittis, libero vitae pretium pharetra, velit est dignissim erat, at cursus quam massa vitae ligula. Suspendisse potenti. In hac habitasse platea dictumst. Donec sit amet finibus justo. Mauris ante dolor, pulvinar vitae feugiat eu, rhoncus nec diam. In ut accumsan diam, faucibus fringilla odio. Nunc id ultricies turpis. Quisque justo quam, tristique sit amet interdum quis, facilisis at mi. Fusce porttitor vel sem ut condimentum. Praesent at libero congue, vulputate elit ut, rhoncus erat. - ` + ` - node.content = content + node.content = content - let createdNode - const createNode = markdownNode => - queryResult([ markdownNode ], - ` + let createdNode + const createNode = markdownNode => + queryResult( + [markdownNode], + ` excerpt frontmatter { title } - `,{ types: [ { name: `MarkdownRemark` } ] }).then(result => { - try { - createdNode = result.data.listNode[0] - expect(createdNode).toMatchSnapshot() - expect(createdNode.excerpt).toMatch(``) - done() - } catch (err) { - done.fail(err) - } - }) + `, + { types: [{ name: `MarkdownRemark` }] } + ).then(result => { + try { + createdNode = result.data.listNode[0] + expect(createdNode).toMatchSnapshot() + expect(createdNode.excerpt).toMatch(``) + done() + } catch (err) { + done.fail(err) + } + }) - const createParentChildLink = jest.fn() - const boundActionCreators = { createNode, createParentChildLink } + const createParentChildLink = jest.fn() + const boundActionCreators = { createNode, createParentChildLink } - onCreateNode({ - node, - loadNodeContent, - boundActionCreators, - }) - }) + onCreateNode({ + node, + loadNodeContent, + boundActionCreators, + }) }) + }) }) diff --git a/packages/gatsby-transformer-remark/src/on-node-create.js b/packages/gatsby-transformer-remark/src/on-node-create.js index 22d7dceef21c6..6c7797fb8f467 100644 --- a/packages/gatsby-transformer-remark/src/on-node-create.js +++ b/packages/gatsby-transformer-remark/src/on-node-create.js @@ -2,12 +2,10 @@ const grayMatter = require(`gray-matter`) const crypto = require(`crypto`) const _ = require(`lodash`) -module.exports = async function onCreateNode({ - node, - getNode, - loadNodeContent, - boundActionCreators, -}, pluginOptions) { +module.exports = async function onCreateNode( + { node, getNode, loadNodeContent, boundActionCreators }, + pluginOptions +) { const { createNode, createParentChildLink } = boundActionCreators // We only care about markdown content. diff --git a/packages/gatsby/src/commands/develop.js b/packages/gatsby/src/commands/develop.js index 69786ac445ee6..3d519377929de 100644 --- a/packages/gatsby/src/commands/develop.js +++ b/packages/gatsby/src/commands/develop.js @@ -176,7 +176,11 @@ async function startServer(program) { // Render an HTML page and serve it. app.use((req, res, next) => { const parsedPath = parsePath(req.path) - if (parsedPath.extname === `` || parsedPath.extname.startsWith(`.html`) || parsedPath.path.endsWith(`/`)) { + if ( + parsedPath.extname === `` || + parsedPath.extname.startsWith(`.html`) || + parsedPath.path.endsWith(`/`) + ) { res.sendFile(directoryPath(`public/index.html`), err => { if (err) { res.status(500).end()