From cede4ff7dc17c80474ded1d263c63f016746161b Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Mon, 6 Jul 2020 23:30:02 -0700 Subject: [PATCH] chore: Extract CodeBlock to CodeHighlight. Conditionally apply language class --- src/components/CodeBlock.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/CodeBlock.js b/src/components/CodeBlock.js index fcc8b435c..77b1cb340 100644 --- a/src/components/CodeBlock.js +++ b/src/components/CodeBlock.js @@ -1,14 +1,19 @@ import React from 'react'; import PropTypes from 'prop-types'; +import cx from 'classnames'; import Highlight from 'prism-react-renderer'; import Prism from 'prismjs'; import styles from './CodeBlock.module.scss'; -const CodeBlock = ({ children, language }) => { +const CodeHighlight = ({ children, language }) => { return ( {({ tokens, getLineProps, getTokenProps }) => ( -
+        
           
             {tokens.map((line, i) => (
               // eslint-disable-next-line react/jsx-key
@@ -26,11 +31,18 @@ const CodeBlock = ({ children, language }) => {
   );
 };
 
-CodeBlock.propTypes = {
+const CodeBlock = ({ children, language }) => (
+  {children}
+);
+
+CodeHighlight.propTypes = {
   children: PropTypes.string.isRequired,
   language: PropTypes.string,
 };
 
-CodeBlock.defaultProps = {};
+CodeBlock.propTypes = {
+  children: PropTypes.string.isRequired,
+  language: PropTypes.string,
+};
 
 export default CodeBlock;