diff --git a/src/mdx/code.js b/src/mdx/code.js index c68a1b2f0e6..1cbf73d9f3f 100644 --- a/src/mdx/code.js +++ b/src/mdx/code.js @@ -43,6 +43,11 @@ export const InlineCode = styled.code` background-color: ${themeGet('colors.neutral.muted')}; border-radius: ${themeGet('radii.2')}; ` +const colorMap = { + 'token comment': '#747458', + 'token function': '#cf3846', + 'token parameter variable': '#277d7b', +} const MonoText = props => @@ -113,18 +118,14 @@ function Code({className = '', prompt, children}) { {tokens.map((line, i) => ( - {line.map((token, key) => ( - - ))} + {line.map((token, key) => { + const tokenProps = getTokenProps({token, key}) + const tokenStyle = colorMap[tokenProps.className] + ? {...tokenProps.style, color: colorMap[tokenProps.className]} + : tokenProps.style + + return + })} ))}