-
Notifications
You must be signed in to change notification settings - Fork 9
/
gatsby-node.ts
42 lines (37 loc) · 1.06 KB
/
gatsby-node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {createFilePath} from 'gatsby-source-filesystem'
import {getPages} from './src/lib/pages'
import {urls} from './src/constants'
import {basename} from 'path'
exports.onCreateNode = ({node, getNode, actions}) => {
const {createNodeField} = actions
if (node.internal.type === `MarkdownRemark`) {
const slug = createFilePath({node, getNode})
createNodeField({
node,
name: `path`,
value: {
notes: `${urls.documents}${slug}`,
slides: `${urls.slideshows}${slug}`
}
})
createNodeField({
node,
name: 'fileBasename',
value: basename(node.fileAbsolutePath, '.md')
})
}
}
exports.onCreateWebpackConfig = ({getConfig, stage}) => {
const config = getConfig()
if (stage.startsWith('develop') && config.resolve) {
config.resolve.alias = {
...config.resolve.alias,
'react-dom': '@hot-loader/react-dom'
}
}
}
exports.createPages = async ({graphql, actions}) => {
const {createPage} = actions
const pages = await getPages(graphql)
pages.forEach(page => createPage(page))
}