|
@ -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, |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}, |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|