diff --git a/gatsby-config.js b/gatsby-config.js index 304862e42..c071f33b6 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -42,6 +42,12 @@ module.exports = { }, }, }, + { + resolve: 'gatsby-source-swiftype', + options: { + path: `${__dirname}/src/data`, + }, + }, 'gatsby-plugin-sass', { resolve: 'gatsby-plugin-manifest', diff --git a/plugins/gatsby-source-swiftype/gatsby-node.js b/plugins/gatsby-source-swiftype/gatsby-node.js new file mode 100644 index 000000000..d155d34fc --- /dev/null +++ b/plugins/gatsby-source-swiftype/gatsby-node.js @@ -0,0 +1,11 @@ +const fs = require('fs'); +const path = require('path'); + +exports.onPreBootstrap = ({ reporter }, pluginOptions) => { + const dataFile = path.join(pluginOptions.path, 'related-pages.json'); + + if (!fs.existsSync(dataFile)) { + reporter.info('Creating related-pages.json file'); + fs.writeFileSync(dataFile, '[]'); + } +}; diff --git a/plugins/gatsby-source-swiftype/package.json b/plugins/gatsby-source-swiftype/package.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/plugins/gatsby-source-swiftype/package.json @@ -0,0 +1 @@ +{}