-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgatsby-node.js
More file actions
54 lines (43 loc) · 1.17 KB
/
gatsby-node.js
File metadata and controls
54 lines (43 loc) · 1.17 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
/**
* 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 { languages, defaultLanguage } = require('./src/i18n-config');
exports.onCreateBabelConfig = props => {
const { actions } = props;
actions.setBabelPlugin({
name: '@babel/plugin-proposal-class-properties',
});
actions.setBabelPlugin({
name: '@babel/plugin-proposal-object-rest-spread',
});
actions.setBabelPlugin({
name: '@babel/plugin-syntax-dynamic-import',
});
actions.setBabelPreset({
name: '@lingui/babel-preset-react',
});
};
exports.onCreatePage = async ({ page, actions }) => {
const { createPage, deletePage } = actions;
return new Promise((resolve, reject) => {
deletePage(page);
languages.map(language => {
const newPage = Object.assign({}, page, {
originalPath: page.path,
path: '/' + language + page.path,
context: {
lang: language,
},
});
createPage(newPage);
if (language === defaultLanguage) {
newPage.path = page.path;
createPage(newPage);
}
});
resolve();
});
};