-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-node.js
More file actions
53 lines (50 loc) · 1.27 KB
/
gatsby-node.js
File metadata and controls
53 lines (50 loc) · 1.27 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
const path = require("path");
async function turnTagsIntoPages({ graphql, actions }) {
// Get a template for the page
const tagTemplate = path.resolve("./src/templates/Tags.js");
// Query all tags
const { data } = await graphql(`
query {
tags: allContentfulTag {
nodes {
name
contentful_id
}
}
}
`);
data.tags.nodes.forEach((tag) => {
let slugifyName = tag.contentful_id.replace(
/[A-Z]/g,
(m) => "-" + m.toLowerCase()
);
actions.createPage({
path: `category/${slugifyName}`,
component: tagTemplate,
context: {
name: tag.name,
id: tag.contentful_id,
},
});
});
}
exports.createPages = async (params) => {
const { actions } = params;
actions.createSlice({
id: `sideMenu`,
component: require.resolve('./src/components/Header/SideMenu.js'),
});
actions.createSlice({
id: `footerArea`,
component: require.resolve('./src/components/Footer/Footer.js'),
});
actions.createSlice({
id: `logoArea`,
component: require.resolve('./src/components/Header/Logo.js'),
});
actions.createSlice({
id: `quickQuote`,
component: require.resolve('./src/components/QuickQuote/QuickQuote.js'),
});
await turnTagsIntoPages(params);
};