exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions;
const moduleTemplate = require.resolve(`./src/templates/moduleTemplate.js`);
const result = await graphql(`
{
allMarkdownRemark {
edges {
node {
frontmatter {
slug
}
`);
// Handle errors
if (result.errors) {
reporter.panicOnBuild(`Error while running GraphQL query.`);
return;
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
if (!node.frontmatter.slug) return;
createPage({
path: node.frontmatter.slug,
component: moduleTemplate,
context: {
// additional data can be passed via context
slug: node.frontmatter.slug,
},
});
const syllabusTemplate = require.resolve(`./src/templates/syllabusTemplate.js`);
path: "/",
component: syllabusTemplate,
division: 0
path: "/intro",
path: "/bronze",
division: 1
path: "/silver",
division: 2
path: "/gold",
division: 3
path: "/plat",
division: 4
};
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions;
const typeDefs = `
type MarkdownRemarkFrontmatter implements Node {
prerequisites: [[String]]
`;
createTypes(typeDefs)