@@ -28,39 +28,43 @@ const ScssDocs: FC = ({ file, capture }: { file?: string; capture?: string }) =>
28
28
const captureStart = `// scss-docs-start ${ capture } `
29
29
const captureEnd = `// scss-docs-end ${ capture } `
30
30
const re = new RegExp ( `${ captureStart } ((?:.|\n)*)${ captureEnd } ` )
31
- const code = re . exec ( _file . node . internal . content ) [ 1 ] . trim ( )
31
+ const code = re . test ( _file . node . internal . content )
32
+ ? re . exec ( _file . node . internal . content ) [ 1 ] . trim ( )
33
+ : null
32
34
33
35
return (
34
- < div className = "highlight" >
35
- < Highlight
36
- code = { code
37
- . replaceAll ( '--#{$prefix}' , '--cui-' )
38
- . replaceAll ( '\n -' , '\n-' )
39
- . replaceAll ( '\n @' , '\n@' ) }
40
- language = "scss"
41
- theme = { { plain : { } , styles : [ ] } }
42
- >
43
- { ( { className, style, tokens, getLineProps, getTokenProps } ) => (
44
- < pre className = { className } style = { { ...style } } >
45
- { tokens . map ( ( line , i ) => {
46
- const lineProps = getLineProps ( { line, key : i } )
47
- return (
48
- < div className = { lineProps . className } key = { i } >
49
- { line . map ( ( token , key ) => {
50
- const tokenProps = getTokenProps ( { token, key } )
51
- return (
52
- < span className = { tokenProps . className } key = { key } >
53
- { tokenProps . children }
54
- </ span >
55
- )
56
- } ) }
57
- </ div >
58
- )
59
- } ) }
60
- </ pre >
61
- ) }
62
- </ Highlight >
63
- </ div >
36
+ code && (
37
+ < div className = "highlight" >
38
+ < Highlight
39
+ code = { code
40
+ . replaceAll ( '--#{$prefix}' , '--cui-' )
41
+ . replaceAll ( '\n -' , '\n-' )
42
+ . replaceAll ( '\n @' , '\n@' ) }
43
+ language = "scss"
44
+ theme = { { plain : { } , styles : [ ] } }
45
+ >
46
+ { ( { className, style, tokens, getLineProps, getTokenProps } ) => (
47
+ < pre className = { className } style = { { ...style } } >
48
+ { tokens . map ( ( line , i ) => {
49
+ const lineProps = getLineProps ( { line, key : i } )
50
+ return (
51
+ < div className = { lineProps . className } key = { i } >
52
+ { line . map ( ( token , key ) => {
53
+ const tokenProps = getTokenProps ( { token, key } )
54
+ return (
55
+ < span className = { tokenProps . className } key = { key } >
56
+ { tokenProps . children }
57
+ </ span >
58
+ )
59
+ } ) }
60
+ </ div >
61
+ )
62
+ } ) }
63
+ </ pre >
64
+ ) }
65
+ </ Highlight >
66
+ </ div >
67
+ )
64
68
)
65
69
}
66
70
0 commit comments