35 lines
914 B
JavaScript
35 lines
914 B
JavaScript
|
const path = require('path')
|
||
|
|
||
|
exports.createPages = async ({ actions, graphql }) => {
|
||
|
const {createPage} = actions;
|
||
|
|
||
|
const courseTemplate = path.resolve(`./src/components/courseTemplate.js`);
|
||
|
const result = await graphql(`{
|
||
|
allMarkdownRemark(
|
||
|
filter: {frontmatter: {
|
||
|
content_type: {eq: "page_education"},
|
||
|
published: {eq: true}}}
|
||
|
){
|
||
|
edges{
|
||
|
node{
|
||
|
html
|
||
|
frontmatter{
|
||
|
title
|
||
|
path
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}`)
|
||
|
|
||
|
if(result.errors){throw result.errors;}
|
||
|
|
||
|
const courses = result.data.allMarkdownRemark.edges;
|
||
|
|
||
|
courses.forEach(({node}) => {
|
||
|
createPage({
|
||
|
path: node.frontmatter.path,
|
||
|
component: courseTemplate
|
||
|
})
|
||
|
})
|
||
|
}
|