mirror of
https://github.com/ruisaraiva19/favycon.git
synced 2026-09-12 19:51:07 +05:00
22 lines
554 B
TypeScript
22 lines
554 B
TypeScript
import React from 'react'
|
|
import Prism from 'prismjs'
|
|
|
|
import styles from './index.module.scss'
|
|
|
|
type CodeHighlightProps = {
|
|
template: string
|
|
}
|
|
|
|
const CodeHighlight = React.forwardRef<HTMLPreElement, CodeHighlightProps>(({ template }, ref) => {
|
|
const htmlCode = Prism.highlight(template, Prism.languages.markup, 'markup')
|
|
return (
|
|
<pre className={styles.root} ref={ref}>
|
|
<code className="language-markup" dangerouslySetInnerHTML={{ __html: htmlCode }}></code>
|
|
</pre>
|
|
)
|
|
})
|
|
|
|
CodeHighlight.displayName = 'CodeHighlight'
|
|
|
|
export { CodeHighlight }
|