1- const componentWithMDXScope = require ( "gatsby-plugin-mdx/component-with-mdx-scope" ) ;
2- const path = require ( "path" ) ;
3- const startCase = require ( "lodash.startcase" ) ;
4- const config = require ( "./config" ) ;
1+ const componentWithMDXScope = require ( 'gatsby-plugin-mdx/component-with-mdx-scope' ) ;
2+
3+ const path = require ( 'path' ) ;
4+
5+ const startCase = require ( 'lodash.startcase' ) ;
6+
7+ const config = require ( './config' ) ;
58
69exports . createPages = ( { graphql, actions } ) => {
710 const { createPage } = actions ;
11+
812 return new Promise ( ( resolve , reject ) => {
913 resolve (
1014 graphql (
@@ -34,11 +38,11 @@ exports.createPages = ({ graphql, actions }) => {
3438 // Create blog posts pages.
3539 result . data . allMdx . edges . forEach ( ( { node } ) => {
3640 createPage ( {
37- path : node . fields . slug ? node . fields . slug : "/" ,
38- component : path . resolve ( " ./src/templates/docs.js" ) ,
41+ path : node . fields . slug ? node . fields . slug : '/' ,
42+ component : path . resolve ( ' ./src/templates/docs.js' ) ,
3943 context : {
40- id : node . fields . id
41- }
44+ id : node . fields . id ,
45+ } ,
4246 } ) ;
4347 } ) ;
4448 } )
@@ -49,18 +53,18 @@ exports.createPages = ({ graphql, actions }) => {
4953exports . onCreateWebpackConfig = ( { actions } ) => {
5054 actions . setWebpackConfig ( {
5155 resolve : {
52- modules : [ path . resolve ( __dirname , " src" ) , " node_modules" ] ,
53- alias : {
54- $components : path . resolve ( __dirname , " src/components" ) ,
55- buble : '@philpl/buble' // to reduce bundle size
56- }
57- }
56+ modules : [ path . resolve ( __dirname , ' src' ) , ' node_modules' ] ,
57+ alias : {
58+ $components : path . resolve ( __dirname , ' src/components' ) ,
59+ buble : '@philpl/buble' , // to reduce bundle size
60+ } ,
61+ } ,
5862 } ) ;
5963} ;
6064
6165exports . onCreateBabelConfig = ( { actions } ) => {
6266 actions . setBabelPlugin ( {
63- name : " @babel/plugin-proposal-export-default-from"
67+ name : ' @babel/plugin-proposal-export-default-from' ,
6468 } ) ;
6569} ;
6670
@@ -69,36 +73,37 @@ exports.onCreateNode = ({ node, getNode, actions }) => {
6973
7074 if ( node . internal . type === `Mdx` ) {
7175 const parent = getNode ( node . parent ) ;
72- let value = parent . relativePath . replace ( parent . ext , "" ) ;
7376
74- if ( value === "index" ) {
75- value = "" ;
77+ let value = parent . relativePath . replace ( parent . ext , '' ) ;
78+
79+ if ( value === 'index' ) {
80+ value = '' ;
7681 }
7782
78- if ( config . gatsby && config . gatsby . trailingSlash ) {
83+ if ( config . gatsby && config . gatsby . trailingSlash ) {
7984 createNodeField ( {
8085 name : `slug` ,
8186 node,
82- value : value === "" ? `/` : `/${ value } /`
87+ value : value === '' ? `/` : `/${ value } /` ,
8388 } ) ;
8489 } else {
8590 createNodeField ( {
8691 name : `slug` ,
8792 node,
88- value : `/${ value } `
93+ value : `/${ value } ` ,
8994 } ) ;
9095 }
9196
9297 createNodeField ( {
93- name : "id" ,
98+ name : 'id' ,
9499 node,
95- value : node . id
100+ value : node . id ,
96101 } ) ;
97102
98103 createNodeField ( {
99- name : " title" ,
104+ name : ' title' ,
100105 node,
101- value : node . frontmatter . title || startCase ( parent . name )
106+ value : node . frontmatter . title || startCase ( parent . name ) ,
102107 } ) ;
103108 }
104109} ;
0 commit comments