2020-06-03 22:18:17 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2020-06-06 00:24:35 +00:00
|
|
|
|
|
|
|
const syllabusTemplate = require.resolve(`./src/templates/syllabusTemplate.js`);
|
|
|
|
createPage({
|
|
|
|
path: "/",
|
|
|
|
component: syllabusTemplate,
|
|
|
|
context: {
|
|
|
|
division: 0
|
|
|
|
},
|
|
|
|
});
|
|
|
|
createPage({
|
|
|
|
path: "/intro",
|
|
|
|
component: syllabusTemplate,
|
|
|
|
context: {
|
|
|
|
division: 0
|
|
|
|
},
|
|
|
|
});
|
|
|
|
createPage({
|
2020-06-08 21:03:15 +00:00
|
|
|
path: "/general",
|
2020-06-06 00:24:35 +00:00
|
|
|
component: syllabusTemplate,
|
|
|
|
context: {
|
|
|
|
division: 1
|
|
|
|
},
|
|
|
|
});
|
|
|
|
createPage({
|
2020-06-08 21:03:15 +00:00
|
|
|
path: "/bronze",
|
2020-06-06 00:24:35 +00:00
|
|
|
component: syllabusTemplate,
|
|
|
|
context: {
|
|
|
|
division: 2
|
|
|
|
},
|
|
|
|
});
|
|
|
|
createPage({
|
2020-06-08 21:03:15 +00:00
|
|
|
path: "/silver",
|
2020-06-06 00:24:35 +00:00
|
|
|
component: syllabusTemplate,
|
|
|
|
context: {
|
|
|
|
division: 3
|
|
|
|
},
|
|
|
|
});
|
|
|
|
createPage({
|
2020-06-08 21:03:15 +00:00
|
|
|
path: "/gold",
|
2020-06-06 00:24:35 +00:00
|
|
|
component: syllabusTemplate,
|
|
|
|
context: {
|
|
|
|
division: 4
|
|
|
|
},
|
|
|
|
});
|
2020-06-08 21:03:15 +00:00
|
|
|
createPage({
|
|
|
|
path: "/plat",
|
|
|
|
component: syllabusTemplate,
|
|
|
|
context: {
|
|
|
|
division: 5
|
|
|
|
},
|
|
|
|
});
|
2020-06-04 22:38:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.createSchemaCustomization = ({ actions }) => {
|
|
|
|
const { createTypes } = actions;
|
|
|
|
const typeDefs = `
|
|
|
|
type MarkdownRemarkFrontmatter implements Node {
|
|
|
|
prerequisites: [[String]]
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
createTypes(typeDefs)
|
2020-06-03 22:18:17 +00:00
|
|
|
};
|