1
1
const prismPresetDictionary = {
2
- ' dracula' : '@theme-ui/prism/presets/dracula.json' ,
2
+ dracula : '@theme-ui/prism/presets/dracula.json' ,
3
3
'duotone-dark' : '@theme-ui/prism/presets/duotone-dark.json' ,
4
4
'duotone-light' : '@theme-ui/prism/presets/duotone-light.json' ,
5
- ' github' : '@theme-ui/prism/presets/github.json' ,
5
+ github : '@theme-ui/prism/presets/github.json' ,
6
6
'night-owl-light' : '@theme-ui/prism/presets/night-owl-light.json' ,
7
7
'night-owl' : '@theme-ui/prism/presets/night-owl.json' ,
8
8
'oceanic-next' : '@theme-ui/prism/presets/oceanic-next.json' ,
@@ -12,30 +12,27 @@ const prismPresetDictionary = {
12
12
'prism-solarizedlight' : '@theme-ui/prism/presets/prism-solarizedlight.json' ,
13
13
'prism-tomorrow' : '@theme-ui/prism/presets/prism-tomorrow.json' ,
14
14
'prism-twilight' : '@theme-ui/prism/presets/prism-twilight.json' ,
15
- ' prism' : '@theme-ui/prism/presets/prism.json' ,
16
- 'shades-or -purple' : '@theme-ui/prism/presets/shades-or -purple.json' ,
15
+ prism : '@theme-ui/prism/presets/prism.json' ,
16
+ 'shades-of -purple' : '@theme-ui/prism/presets/shades-of -purple.json' ,
17
17
'theme-ui' : '@theme-ui/prism/presets/theme-ui.json' ,
18
- ' ultramin' : '@theme-ui/prism/presets/ultramin.json' ,
18
+ ultramin : '@theme-ui/prism/presets/ultramin.json' ,
19
19
'vs-dark' : '@theme-ui/prism/presets/vs-dark.json' ,
20
20
}
21
21
22
22
exports . onPreInit = ( __ , options ) => {
23
- let { themeModulePath} = options
24
- if ( themeModulePath ) {
25
- options . themeModulePath = require ( themeModulePath )
26
- }
27
-
28
- if ( prismPreset in prismPresetDictionary ) {
29
- prismPreset = prismPresetDictionary [ prismPreset ]
30
- }
23
+ if ( prismPreset in prismPresetDictionary ) {
24
+ prismPreset = prismPresetDictionary [ prismPreset ]
25
+ }
31
26
32
- if ( prismPreset ) {
33
- try {
34
- options . prismPreset = require ( prismPreset )
35
- } catch {
36
- reporter . error ( `It appears the prism dependency is not installed. Try running \`${ generateInstallInstructions ( ) } \n\n${ prismPreset } \`` )
37
- }
27
+ if ( prismPreset ) {
28
+ try {
29
+ options . prismPreset = require ( prismPreset )
30
+ } catch {
31
+ reporter . error (
32
+ `It appears the prism dependency is not installed. Try running \`${ generateInstallInstructions ( ) } \n\n${ prismPreset } \``
33
+ )
38
34
}
35
+ }
39
36
}
40
37
41
38
function generateInstallInstructions ( ) {
@@ -44,48 +41,41 @@ function generateInstallInstructions() {
44
41
const packageMangerConfigKey = `cli.packageManager`
45
42
const PACKAGE_MANGER = getConfigStore ( ) . get ( packageMangerConfigKey ) || `yarn`
46
43
47
- const installKeyWord = PACKAGE_MANGER === `yarn` ? " add" : " install"
44
+ const installKeyWord = PACKAGE_MANGER === `yarn` ? ' add' : ' install'
48
45
49
46
return `${ PACKAGE_MANGER } ${ installKeyWord } `
50
47
}
51
48
52
49
exports . createSchemaCustomization = ( { actions } ) => {
53
- const { createTypes } = actions
54
-
55
- createTypes ( `
50
+ const { createTypes } = actions
51
+
52
+ createTypes ( `
56
53
type ThemeUiConfig implements Node {
57
- themeModule: JSON,
58
- themeModulePath: JSON,
59
- moduleExportName: String,
60
54
prismPreset: JSON,
61
55
}
62
56
` )
57
+ }
58
+
59
+ exports . sourceNodes = (
60
+ { actions, createContentDigest } ,
61
+ { prismPreset = { } }
62
+ ) => {
63
+ const { createNode } = actions
64
+
65
+ const themeUiConfig = {
66
+ prismPreset,
63
67
}
64
-
65
- exports . sourceNodes = (
66
- { actions, createContentDigest } ,
67
- { prismPreset, moduleExportName = 'default' , themeModule, themeModulePath}
68
- ) => {
69
- const { createNode } = actions
70
-
71
- const themeUiConfig = {
72
- themeModule,
73
- themeModulePath,
74
- moduleExportName,
75
- prismPreset
76
- }
77
-
78
- createNode ( {
79
- ...themeUiConfig ,
80
- id : `gatsby-plugin-theme-ui-config` ,
81
- parent : null ,
82
- children : [ ] ,
83
- internal : {
84
- type : `ThemeUiConfig` ,
85
- contentDigest : createContentDigest ( themeUiConfig ) ,
86
- content : JSON . stringify ( themeUiConfig ) ,
87
- description : `Options for gatsby-plugin-theme-ui` ,
88
- } ,
89
- } )
90
- }
91
68
69
+ createNode ( {
70
+ ...themeUiConfig ,
71
+ id : `gatsby-plugin-theme-ui-config` ,
72
+ parent : null ,
73
+ children : [ ] ,
74
+ internal : {
75
+ type : `ThemeUiConfig` ,
76
+ contentDigest : createContentDigest ( themeUiConfig ) ,
77
+ content : JSON . stringify ( themeUiConfig ) ,
78
+ description : `Options for gatsby-plugin-theme-ui` ,
79
+ } ,
80
+ } )
81
+ }
0 commit comments