const {createFilePath} = require('gatsby-source-filesystem') const path = require('path') exports.onCreateNode = ({node, getNode, actions}) => { const {createNodeField} = actions if (node.internal.type === 'MarkdownRemark') { const slug = createFilePath({node, getNode, basePath: 'content', trailingSlash: false}) createNodeField({ node, name: 'slug', value: slug }) } } exports.createPages = ({graphql, actions}) => { const {createPage} = actions return graphql(` { allMarkdownRemark { edges { node { id fields { slug } html } } } } `).then(result => { result.data.allMarkdownRemark.edges.forEach(({node}) => { createPage({ path: node.fields.slug, component: path.resolve('./src/templates/Page.js'), context: { slug: node.fields.slug } }) }) }) }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
content | Folder | 0755 |
|
|
public | Folder | 0755 |
|
|
src | Folder | 0755 |
|
|
LICENSE | File | 1.05 KB | 0644 |
|
gatsby-browser.js | File | 250 B | 0644 |
|
gatsby-config.js | File | 2.84 KB | 0644 |
|
gatsby-node.js | File | 974 B | 0644 |
|
gatsby-ssr.js | File | 179 B | 0644 |
|
package-lock.json | File | 724.8 KB | 0644 |
|
package.json | File | 1.4 KB | 0644 |
|