Skip to content

Commit 58cece8

Browse files
Laurie BarthLaurie Barth
authored andcommitted
include prism as pre
1 parent ca37220 commit 58cece8

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

packages/gatsby-plugin-theme-ui/src/provider.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
/** @jsx jsx */
2-
import {
3-
jsx,
4-
ThemeProvider,
5-
merge
6-
} from 'theme-ui'
2+
import { jsx, ThemeProvider, merge } from 'theme-ui'
73
import theme from './index'
84
import components from './components'
95
import useThemeUiConfig from './hooks/configOptions'
106

11-
12-
const Root = ({children}) => {
7+
const Root = ({ children }) => {
138
const themeUiConfig = useThemeUiConfig()
14-
const {themeModule, themeModulePath, moduleExportName} = themeUiConfig
9+
const { themeModule, themeModulePath, moduleExportName } = themeUiConfig
1510

1611
let themeWrapper
1712
if (themeModule) {
@@ -21,25 +16,31 @@ const Root = ({children}) => {
2116
if (themeModulePath) {
2217
themeWrapper = themeModulePath
2318
}
24-
25-
if(themeWrapper && (moduleExportName in themeWrapper)) {
19+
20+
if (themeWrapper && moduleExportName in themeWrapper) {
2621
themeWrapper = themeWrapper[moduleExportName]
2722
}
2823

24+
if (prismPreset) {
25+
themeWrapper = merge(themeWrapper, {
26+
styles: {
27+
pre: {
28+
...prismPreset,
29+
},
30+
},
31+
})
32+
}
33+
2934
themeWrapper = merge(themeWrapper, {
30-
prism: prismPreset,
31-
...theme
35+
...theme,
3236
})
3337
return (
3438
<ThemeProvider theme={themeWrapper} components={components}>
35-
{children}
39+
{children}
3640
</ThemeProvider>
3741
)
3842
}
3943

4044
export const wrapRootElement = ({ element }) => {
41-
return (
42-
<Root>{element}</Root>
43-
)
45+
return <Root>{element}</Root>
4446
}
45-

0 commit comments

Comments
 (0)