-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
34 lines (27 loc) · 924 Bytes
/
gatsby-node.js
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
const path = require('path');
const processModel = require('./src/model/index.js');
module.exports.createPages = ({ actions, graphql }) => {
const { createPage } = actions;
const langs = ['ru', 'en']; // TODO: there store and how to pass languages here?
const lang = 'ru'; // TODO: how to pass current language here?
const processedModel = processModel.expand(require('./model/model'), lang);
const model = processedModel.model;
model.forEach(page => {
let template;
page.type = page.type || 'article';
switch (page.type) {
default:
template = path.resolve(`src/components/Page/Page.tsx`);
}
return createPage({
path: page.url,
component: template,
context: {
...page,
model,
langs,
lang
},
});
});
}