Skip to content

Commit

Permalink
feat: add local plugin that creates the json file that will be writte…
Browse files Browse the repository at this point in the history
…n to
jerelmiller committed Aug 12, 2020
1 parent 1329519 commit 0568e5c
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -42,6 +42,12 @@ module.exports = {
},
},
},
{
resolve: 'gatsby-source-swiftype',
options: {
path: `${__dirname}/src/data`,
},
},
'gatsby-plugin-sass',
{
resolve: 'gatsby-plugin-manifest',
11 changes: 11 additions & 0 deletions plugins/gatsby-source-swiftype/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -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, '[]');
}
};
1 change: 1 addition & 0 deletions plugins/gatsby-source-swiftype/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit 0568e5c

Please sign in to comment.