site/gatsby-node.js

35 lines
914 B
JavaScript
Raw Normal View History

2020-01-15 17:45:50 +03:00
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
})
})
}