-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.js
41 lines (31 loc) · 1.08 KB
/
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
/* eslint-disable @typescript-eslint/no-var-requires */
const puppeteer = require('puppeteer');
const {
PAGES_QUERY,
buildBlogListPagination,
buildBlogPosts,
buildFactionPages,
buildPages,
} = require('./meta/node');
let browser = null;
exports.onPreInit = async () => {
browser = await puppeteer.launch({ headless: true });
};
exports.onPostBuild = async () => {
await browser.close();
};
exports.createPages = async ({ graphql, actions }) => {
const result = await graphql(PAGES_QUERY);
if (result.errors) return;
console.log('\nCreating Pages...');
buildPages(result.data.pages.nodes, actions.createPage);
console.log('\nCreating Downloads...');
buildPages(result.data.download.nodes, actions.createPage);
console.log('\nCreating Blog Posts...');
buildBlogPosts(result.data.posts.nodes, actions.createPage);
console.log('\nPaginating Blog Posts List...');
buildBlogListPagination(result.data.posts.nodes, actions.createPage);
console.log('\nCreating Faction Pages...');
buildFactionPages(result.data.factions.nodes, actions.createPage);
console.log();
};