Skip to content

Commit b19fcc2

Browse files
committed
simplified code
1 parent 05585b4 commit b19fcc2

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/mdx/code.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,13 @@ function Code({className = '', prompt, children}) {
113113
<CodeBlock className={highlightClassName} style={style} code={code}>
114114
{tokens.map((line, i) => (
115115
<Box key={i} {...getLineProps({line, key: i})}>
116-
{line.map((token, key) => (
117-
<MonoText
118-
key={key}
119-
{...{
120-
...getTokenProps({token, key}),
121-
style: {
122-
...getTokenProps({token, key}).style,
123-
color:
124-
getTokenProps({token, key}).className === 'token comment'
125-
? '#747458'
126-
: getTokenProps({token, key}).className === 'token parameter variable'
127-
? '#277d7b'
128-
: getTokenProps({token, key}).style.color,
129-
},
130-
}}
131-
/>
132-
))}
116+
{line.map((token, key) => {
117+
const tokenProps = getTokenProps({token, key})
118+
const tokenStyle =
119+
tokenProps.className === 'token comment' ? {...tokenProps.style, color: '#747458'} : tokenProps.style
120+
121+
return <MonoText key={key} {...tokenProps} style={tokenStyle} />
122+
})}
133123
</Box>
134124
))}
135125
</CodeBlock>

0 commit comments

Comments
 (0)