Skip to content

Commit

Permalink
feat(v2): #5 building skeleton to be able to see the pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ajfisher committed Nov 30, 2019
1 parent 243a002 commit 385e65e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
8 changes: 8 additions & 0 deletions site/gatsby-config.js
Expand Up @@ -27,6 +27,14 @@ module.exports = {
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
`gatsby-transformer-remark`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `content`,
path: `${__dirname}/src/content`,
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
Expand Down
51 changes: 45 additions & 6 deletions site/gatsby-node.js
@@ -1,7 +1,46 @@
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
const path = require(`path`);

// You can delete this file if you're not using it
exports.createPages = async ({ actions, graphql }) => {
const { createPage } = actions
const result = await graphql(`
{
allMarkdownRemark {
edges {
node {
frontmatter {
slug
date(formatString: "YYYY/MM/DD")
layout
}
}
}
}
}
`)
if (result.errors) {
console.error(result.errors)
}
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
console.log(node.frontmatter.slug);
// TODO fix this to use a date form.
//
const context = {
slug: node.frontmatter.slug
};

if (node.frontmatter.layout.startsWith('page')) {
createPage({
path: node.frontmatter.slug,
component: path.resolve(`src/templates/post.js`),
context
});
} else {
console.log(node.frontmatter.date + '/' + node.frontmatter.slug);
createPage({
path: node.frontmatter.date + '/' + node.frontmatter.slug,
component: path.resolve(`src/templates/post.js`),
context
});
}
});
}

0 comments on commit 385e65e

Please sign in to comment.