forked from pingcap/website-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-node.js
More file actions
40 lines (31 loc) · 917 Bytes
/
Copy pathgatsby-node.js
File metadata and controls
40 lines (31 loc) · 917 Bytes
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
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
// You can delete this file if you're not using it
const createDocs = require('./create-pages/doc')
const createIntlPages = require('./create-pages/intl')
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
if (node.internal.type === 'Mdx') {
const fileNode = getNode(node.parent)
createNodeField({
node,
name: 'langCollection',
value: fileNode.sourceInstanceName,
})
createNodeField({
node,
name: 'relativePath',
value: fileNode.relativePath,
})
}
}
exports.createPages = async ({ actions, graphql }) => {
const { createPage, createRedirect } = actions
createDocs({ graphql, createPage, createRedirect })
}
exports.onCreatePage = ({ page, actions }) => {
createIntlPages({ page, actions })
}