2020-04-27 17:42:40 +00:00
|
|
|
import React from 'react';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import SyntaxHighlighter from 'react-syntax-highlighter';
|
|
|
|
import { docco } from 'react-syntax-highlighter/dist/esm/styles/hljs';
|
|
|
|
|
|
|
|
function CodeBlock({ children, language = 'html', full = false, wrap = false }) {
|
|
|
|
var fullClass = classnames({ 'is-code-full': full });
|
|
|
|
var codeClass = classnames({ code: true, 'code-wrap': wrap });
|
|
|
|
return (
|
|
|
|
<div className={fullClass}>
|
|
|
|
<div className={codeClass}>
|
2021-07-06 17:58:53 +00:00
|
|
|
<SyntaxHighlighter language={language} style={docco} wrapLongLines={full}>{children}</SyntaxHighlighter>
|
2020-04-27 17:42:40 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default CodeBlock;
|