-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
48 lines (42 loc) · 900 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const urlUslug = require('url-slug');
exports.createPages = async ({ actions, graphql, reporter }) => {
const result = await graphql(`
query{
allStrapiPages(filter:{name: { ne:"Home" }}){
nodes{
name
id
}
}
allStrapiPropierties{
nodes{
id
name
}
}
}
`)
if(result.errors){
reporter.panic("No results", result.errors);
}
const pages = result.data.allStrapiPages.nodes;
const propierties = result.data.allStrapiPropierties.nodes;
pages.forEach(page => {
actions.createPage({
path: urlUslug(page.name),
component: require.resolve('./src/templates/Pages.js'),
context: {
id: page.id,
}
})
})
propierties.forEach(propierty => {
actions.createPage({
path: urlUslug(propierty.name),
component: require.resolve('./src/templates/Propierty.js'),
context: {
id: propierty.id,
}
})
})
}