Skip to content

Commit e16b824

Browse files
Laurie BarthLaurie Barth
authored andcommitted
add dictionary to accept all strings
1 parent c0ba394 commit e16b824

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

packages/gatsby-plugin-theme-ui/gatsby-node.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
1+
const prismPresetDictionary = {
2+
'dracula': '@theme-ui/prism/presets/dracula.json',
3+
'duotone-dark': '@theme-ui/prism/presets/duotone-dark.json',
4+
'duotone-light': '@theme-ui/prism/presets/duotone-light.json',
5+
'github': '@theme-ui/prism/presets/github.json',
6+
'night-owl-light': '@theme-ui/prism/presets/night-owl-light.json',
7+
'night-owl': '@theme-ui/prism/presets/night-owl.json',
8+
'oceanic-next': '@theme-ui/prism/presets/oceanic-next.json',
9+
'prism-coy': '@theme-ui/prism/presets/prism-coy.json',
10+
'prism-dark': '@theme-ui/prism/presets/prism-dark.json',
11+
'prism-funky': '@theme-ui/prism/presets/prism-funky.json',
12+
'prism-solarizedlight': '@theme-ui/prism/presets/prism-solarizedlight.json',
13+
'prism-tomorrow': '@theme-ui/prism/presets/prism-tomorrow.json',
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',
17+
'theme-ui': '@theme-ui/prism/presets/theme-ui.json',
18+
'ultramin': '@theme-ui/prism/presets/ultramin.json',
19+
'vs-dark': '@theme-ui/prism/presets/vs-dark.json',
20+
}
21+
122
exports.onPreInit = (__, options) => {
223
let {themeModulePath} = options
324
if(themeModulePath) {
425
options.themeModulePath = require(themeModulePath)
526
}
27+
28+
if(prismPreset in prismPresetDictionary) {
29+
prismPreset = prismPresetDictionary[prismPreset]
30+
}
31+
632
if(prismPreset) {
733
try {
8-
options.prismPreset = require(`@theme-ui/prism/presets/${prismPreset}.json`)
34+
options.prismPreset = require(prismPreset)
935
} catch {
10-
reporter.error(`It appears the prism dependency is not installed. Try running \`${generateInstallInstructions()} @theme-ui/prism\``)
36+
reporter.error(`It appears the prism dependency is not installed. Try running \`${generateInstallInstructions()}\n\n${prismPreset}\``)
1137
}
1238
}
1339
}

0 commit comments

Comments
 (0)