Skip to content

Commit f2e4a97

Browse files
committed
docs: update theme
1 parent 7270312 commit f2e4a97

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

packages/docs/src/components/ScssDocs.tsx

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,43 @@ const ScssDocs: FC = ({ file, capture }: { file?: string; capture?: string }) =>
2828
const captureStart = `// scss-docs-start ${capture}`
2929
const captureEnd = `// scss-docs-end ${capture}`
3030
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
3234

3335
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+
)
6468
)
6569
}
6670

0 commit comments

Comments
 (0)