forked from oceanprotocol/market
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
83 lines (73 loc) · 2.17 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const createFields = require('./gatsby/createFields')
const createMarkdownPages = require('./gatsby/createMarkdownPages')
const execSync = require('child_process').execSync
// Write out repo metadata
execSync(`node ./scripts/write-repo-metadata > repo-metadata.json`, {
stdio: 'inherit'
})
// Generate GraphQl typings for urql
// execSync(`npm run graphql:graphTypes`, { stdio: 'inherit' })
// Generate Apollo typings
execSync(`npm run apollo:codegen`, { stdio: 'inherit' })
// Fetch EVM networks metadata
execSync(
`node ./scripts/write-networks-metadata > content/networks-metadata.json`,
{
stdio: 'inherit'
}
)
//Extend ContentJson to support optional field "optionalCookies" in gdpr.json
//Extend PublishJsonData to support optional fields for disclaimers
exports.sourceNodes = ({ actions }) => {
const { createTypes } = actions
const typeDefs = `
type ContentJson implements Node {
accept: String
reject: String
close: String
configure: String
optionalCookies: [Cookie!]
}
type Cookie {
title: String!
desc: String!
cookieName: String!
}
type PublishJsonData implements Node {
disclaimer: String
disclaimerValues: [String!]
}
`
createTypes(typeDefs)
}
exports.onCreateNode = ({ node, actions, getNode }) => {
createFields(node, actions, getNode)
}
exports.createPages = async ({ graphql, actions }) => {
await createMarkdownPages(graphql, actions)
}
exports.onCreatePage = async ({ page, actions }) => {
const { createPage } = actions
// page.matchPath is a special key that's used for matching pages
// only on the client.
const handleClientSideOnlyAsset = page.path.match(/^\/asset/)
const handleClientSideOnlyAccount = page.path.match(/^\/profile/)
if (handleClientSideOnlyAsset) {
page.matchPath = '/asset/*'
// Update the page.
createPage(page)
} else if (handleClientSideOnlyAccount) {
page.matchPath = '/profile/*'
createPage(page)
}
}
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
node: {
// 'fs' fix for ocean.js
fs: 'empty'
},
// fix for 'got'/'swarm-js' dependency
externals: ['got']
})
}