(props: CodeBlockProps)
| 8 | } |
| 9 | |
| 10 | export const CodeBlock = (props: CodeBlockProps) => { |
| 11 | const { title, lang, children, ...rest } = props |
| 12 | |
| 13 | const extLang = title.split('.').pop() |
| 14 | const resolvedLang = extLang !== lang ? extLang : lang |
| 15 | |
| 16 | return ( |
| 17 | <Box |
| 18 | {...rest} |
| 19 | data-lang={lang} |
| 20 | spaceY="0!" |
| 21 | marginY="1.6em" |
| 22 | rounded="10px" |
| 23 | css={{ |
| 24 | '& pre.shiki': { |
| 25 | roundedTop: '0!', |
| 26 | roundedBottom: 'lg!', |
| 27 | shadow: 'none!' |
| 28 | } |
| 29 | }} |
| 30 | > |
| 31 | <HStack |
| 32 | bg="bg.muted" |
| 33 | px="4" |
| 34 | py="3" |
| 35 | roundedTop="lg" |
| 36 | borderBottomWidth="1px" |
| 37 | > |
| 38 | {resolvedLang && <CodeLangIcon type={resolvedLang} />} |
| 39 | <Box as="p" textStyle="sm" fontFamily="mono"> |
| 40 | {title} |
| 41 | </Box> |
| 42 | </HStack> |
| 43 | {children} |
| 44 | </Box> |
| 45 | ) |
| 46 | } |
| 47 | |
| 48 | type CodeLang = |
| 49 | | 'tsx' |
nothing calls this directly
no outgoing calls
no test coverage detected