@@ -23,6 +23,7 @@ import {PatternVariantFontMatter, PatternFrontMatter} from '../../types';
23
23
import PageMeta from '../PageMeta' ;
24
24
import { Stack , Row } from '../Stack' ;
25
25
import { Box } from '../Box' ;
26
+ import Code from '../Code' ;
26
27
import { Lede } from '../Lede' ;
27
28
import { Heading } from '../Heading' ;
28
29
import PatternsExample from '../PatternsExample' ;
@@ -60,10 +61,17 @@ function codeAsContext(): Plugin {
60
61
meta : Record < string , any > ;
61
62
} [ ] = [ ] ;
62
63
visit ( tree , 'code' , ( node , index , parent ) => {
63
- try {
64
- codes . push ( { node, index : index ! , parent, meta : JSON . parse ( node . meta ) } ) ;
65
- } catch ( error ) {
66
- // Just ignore this block
64
+ if ( node . meta ) {
65
+ try {
66
+ codes . push ( {
67
+ node,
68
+ index : index ! ,
69
+ parent,
70
+ meta : JSON . parse ( node . meta ) ,
71
+ } ) ;
72
+ } catch ( error ) {
73
+ // Just ignore this block
74
+ }
67
75
}
68
76
} ) ;
69
77
@@ -263,7 +271,7 @@ const BaseMarkdown = ({
263
271
< Image fill src = { src } alt = { alt ?? '' } />
264
272
</ div >
265
273
) : null ,
266
- code : function Code ( {
274
+ code : function MdCode ( {
267
275
inline,
268
276
// @ts -expect-error Unsure how to tell react-markdown this prop is
269
277
// being injected by a plugin
@@ -301,7 +309,9 @@ const BaseMarkdown = ({
301
309
) ;
302
310
}
303
311
304
- return < code > { ( children ?. [ 0 ] as string ) ?? '' } </ code > ;
312
+ return (
313
+ < Code code = { { title : '' , code : ( children ?. [ 0 ] as string ) ?? '' } } />
314
+ ) ;
305
315
} ,
306
316
...components ,
307
317
} }
0 commit comments