1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 09:44:53 +01:00
market/gatsby/createFields.js

28 lines
612 B
JavaScript
Raw Normal View History

2020-07-17 14:59:20 +02:00
const { createFilePath } = require('gatsby-source-filesystem')
function createMarkdownFields(node, actions, getNode) {
const { createNodeField } = actions
// Automatically create slugs for specific node types,
2020-07-17 15:16:00 +02:00
// relative to ./content/pages/
2020-07-17 14:59:20 +02:00
const { type } = node.internal
if (type === 'MarkdownRemark') {
// Create a slug from the file path & name
const slug = createFilePath({
node,
getNode,
2020-07-17 15:16:00 +02:00
basePath: 'pages/',
2020-07-17 14:59:20 +02:00
trailingSlash: false
})
createNodeField({
name: 'slug',
node,
value: slug
})
}
}
module.exports = createMarkdownFields