-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathgatsby-node.ts
79 lines (73 loc) · 2.5 KB
/
gatsby-node.ts
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
import type { GatsbyNode } from 'gatsby'
import resolvers from './gatsby/create-resolvers'
import schema from './gatsby/customize-schema'
import {
createFundraiserSchemaCustomization,
createFundraisersFromMarkdown,
} from './gatsby/fundraisers/transformers'
import { sourceNeedsAssessments } from './gatsby/needs-assessment/sourceNeedsAssessmentData'
import {
createPhotoResolvers,
createPhotoSchemaCustomization,
} from './gatsby/photos/photos'
import transformers from './gatsby/transform-nodes'
/*
Customize the GraqphQL Schema
================================================================================
*/
export const createSchemaCustomization: GatsbyNode['createSchemaCustomization'] =
(args) => {
schema.definePageTypes(args)
schema.definePlaceTypes(args)
schema.defineNeedTypes(args)
schema.defineTeamTypes(args)
createFundraiserSchemaCustomization(args)
createPhotoSchemaCustomization(args)
}
/*
Source Nodes
================================================================================
*/
export const sourceNodes: GatsbyNode['sourceNodes'] = async (args) => {
await sourceNeedsAssessments(args)
}
/*
Transform Nodes
================================================================================
*/
export const onCreateNode: GatsbyNode['onCreateNode'] = (args) => {
transformers.createGenericPagesFromMarkdown(args)
transformers.createRegionsFromMarkdown(args)
transformers.createSubregionsFromMarkdown(args)
transformers.createRoutesFromMarkdown(args)
transformers.createTeamRolesFromMarkdown(args)
transformers.createTeamMembersFromMarkdown(args)
transformers.createLineItemsFromJson(args)
createFundraisersFromMarkdown(args)
}
/*
Create Resolvers for Looking Up Related Nodes
================================================================================
*/
export const createResolvers: GatsbyNode['createResolvers'] = (args) => {
resolvers.resolveRegionFields(args)
resolvers.resolveSubregionFields(args)
resolvers.resolveTeamMemberFields(args)
createPhotoResolvers(args)
}
/*
Config
================================================================================
*/
// https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#manual-babel-setup
// This should really be handled by Gatsby but here we are
export const onCreateBabelConfig: GatsbyNode['onCreateBabelConfig'] = ({
actions: { setBabelPlugin },
}) => {
setBabelPlugin({
name: '@babel/plugin-transform-react-jsx',
options: {
runtime: 'automatic',
},
})
}