diff --git a/gatsby-config.js b/gatsby-config.js index 60b0a76..f86018c 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -10,12 +10,19 @@ module.exports = { "gatsby-plugin-image", "gatsby-plugin-sharp", "gatsby-transformer-remark", + { + resolve: "gatsby-source-filesystem", + options: { + name: "reference", + path: `${__dirname}/src/markdown/Reference/`, + }, + }, { resolve: "gatsby-source-filesystem", options: { name: "markdown", path: `${__dirname}/src/markdown/`, }, - }, + } ], -} \ No newline at end of file +} diff --git a/gatsby-node.js b/gatsby-node.js new file mode 100644 index 0000000..bc15757 --- /dev/null +++ b/gatsby-node.js @@ -0,0 +1,53 @@ +const path = require(`path`); +const { createFilePath } = require(`gatsby-source-filesystem`); +/* +exports.onCreateNode = ({ node, getNode, actions }) => { + const { createNodeField } = actions; + if (node.internal.type === `MarkdownRemark`) { + const slug = createFilePath({ node, getNode, basePath: `reference` }); + createNodeField({ + node, + name: `slug`, + value: slug, + }); + } +}; +*/ +exports.createPages = ({ graphql, actions }) => { + const { createPage } = actions; + return new Promise((resolve, reject) => { + graphql(` + query ReferencePagesQuery { + allMarkdownRemark( + filter: {fileAbsolutePath: {glob: "**/Reference/**"}} + sort: {frontmatter: {title: ASC}} + ) { + nodes { + id + frontmatter { + title + slug + } + url: gatsbyPath(filePath: "/reference/{markdownRemark.frontmatter__slug}") + } + } + } + `).then(result => { + console.log(result); + result.data.allMarkdownRemark.nodes.forEach((node) => { + console.log(node); + const slug = node.frontmatter.slug; + createPage({ + path: node.url, + component: path.resolve(`./src/templates/reference-page.js`), + context: { + slug: slug, + title: node.frontmatter.title, + id: node.id + }, + }); + }); + resolve(); + }); + }); +}; diff --git a/src/layout/Header.js b/src/layout/Header.js index 3b0d2a0..9b01b84 100644 --- a/src/layout/Header.js +++ b/src/layout/Header.js @@ -60,7 +60,7 @@ const Header = () => { />