Browse Source

Removed HTML boilerplate from examples folder to simplify build script

main
Brian Vaughn 7 years ago
parent
commit
f14eb61e5f
  1. 3
      examples/index.html
  2. 30
      gatsby-node.js

3
examples/index.html

@ -1,3 +0,0 @@
<div id="root">
<!-- This div's content will be managed by React. -->
</div>

30
gatsby-node.js

@ -168,25 +168,21 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
}); });
// Create Codepen example pages // Create Codepen example pages
const htmlTemplate = fs.readFileSync('./examples/index.html', 'utf8');
fs.readdirSync('./examples').forEach(file => { fs.readdirSync('./examples').forEach(file => {
// Only create pages for the JS files const slug = file.substring(0, file.length - 3); // Trim extension
if (file.endsWith('.js')) { const jsTemplate = fs.readFileSync(`./examples/${file}`, 'utf8');
const slug = file.substring(0, file.length - 3);
const jsTemplate = fs.readFileSync(`./examples/${file}`, 'utf8'); createPage({
path: `/examples/${slug}`,
createPage({ component: resolve('./src/templates/codepen-example.js'),
path: `/examples/${slug}`, context: {
component: resolve('./src/templates/codepen-example.js'), slug,
context: { payload: {
slug, html: '<div id="root"></div>',
payload: { js: jsTemplate,
html: htmlTemplate,
js: jsTemplate,
},
}, },
}); },
} });
}); });
}; };

Loading…
Cancel
Save