pure/site/components/CodeBlock.js
2021-07-06 10:58:53 -07:00

19 lines
681 B
JavaScript

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}>
<SyntaxHighlighter language={language} style={docco} wrapLongLines={full}>{children}</SyntaxHighlighter>
</div>
</div>
);
}
export default CodeBlock;