@@ -10,7 +10,10 @@ import theme from "shiki/themes/material-darker.json";
10
10
export function Preview ( props ) {
11
11
return (
12
12
< div className = "preview" >
13
- < ErrorBoundary resetKeys = { [ props . code ] } FallbackComponent = { ErrorFallback } >
13
+ < ErrorBoundary
14
+ resetKeys = { [ props . input . mdx , props . input . css , props . input . config ] }
15
+ FallbackComponent = { ErrorFallback }
16
+ >
14
17
< InnerPreview { ...props } />
15
18
</ ErrorBoundary >
16
19
</ div >
@@ -25,13 +28,15 @@ function ErrorFallback({ error }) {
25
28
) ;
26
29
}
27
30
28
- function InnerPreview ( { code } ) {
31
+ function InnerPreview ( { input } ) {
29
32
const [ Content , setContent ] = useState ( undefined ) ;
30
33
const [ error , setError ] = useState ( undefined ) ;
31
34
useEffect ( ( ) => {
32
- compile ( code , {
35
+ compile ( input . mdx , {
33
36
outputFormat : "function-body" ,
34
- remarkPlugins : [ [ remarkCodeHike , { autoImport : false , theme } ] ] ,
37
+ remarkPlugins : [
38
+ [ remarkCodeHike , { ...input . config , autoImport : false , theme } ] ,
39
+ ] ,
35
40
} )
36
41
. then ( ( c ) => {
37
42
return run ( String ( c ) , runtime ) ;
@@ -44,7 +49,7 @@ function InnerPreview({ code }) {
44
49
setError ( e . message ) ;
45
50
console . error ( { e } ) ;
46
51
} ) ;
47
- } , [ code ] ) ;
52
+ } , [ input . mdx , input . css , input . config ] ) ;
48
53
// console.log(error);
49
54
return (
50
55
< >
0 commit comments