|
| 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 | + |
1 | 22 | exports.onPreInit = (__, options) => {
|
2 | 23 | let {themeModulePath} = options
|
3 | 24 | if(themeModulePath) {
|
4 | 25 | options.themeModulePath = require(themeModulePath)
|
5 | 26 | }
|
| 27 | + |
| 28 | + if(prismPreset in prismPresetDictionary) { |
| 29 | + prismPreset = prismPresetDictionary[prismPreset] |
| 30 | + } |
| 31 | + |
6 | 32 | if(prismPreset) {
|
7 | 33 | try {
|
8 |
| - options.prismPreset = require(`@theme-ui/prism/presets/${prismPreset}.json`) |
| 34 | + options.prismPreset = require(prismPreset) |
9 | 35 | } 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}\``) |
11 | 37 | }
|
12 | 38 | }
|
13 | 39 | }
|
|
0 commit comments