generated from skyward-digital/next-starter-prismic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sm-resolver.js
34 lines (29 loc) · 944 Bytes
/
sm-resolver.js
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
import * as Slices from './slices'
const __allSlices = { ...Slices, }
const NotFound = ({ sliceName, slice, i }) => {
console.error(`[sm-resolver] component "${sliceName}" not found at index ${i}.`)
console.warn(`slice data: ${slice}`)
return process.env.NODE_ENV !== 'production' ? (
<div
style={{
height: '30vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
textAlign: 'center',
background: '#FAFAFA'
}}
>
<h2>
Slice "{sliceName}" not found.
</h2>
<p style={{ maxWidth: '320px', fontSize: '16px' }}>
Check that you registered this component in your slices library!
</p>
</div>
) : null
}
export default function SliceResolver({ sliceName, ...rest }) {
return __allSlices[sliceName] ? __allSlices[sliceName] : () => <NotFound sliceName={sliceName} {...rest} />
}