-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create custom code block that renders a terminal for shell lang…
…uages
- Loading branch information
1 parent
9cc58b1
commit ca27f28
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/@newrelic/gatsby-theme-newrelic/components/CodeBlock.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import CodeBlock from '@newrelic/gatsby-theme-newrelic/src/components/CodeBlock'; | ||
import Terminal from '../../../components/Terminal'; | ||
import { isShellLanguage } from '../../../utils/codeBlock'; | ||
|
||
const CustomCodeBlock = ({ language, children, ...props }) => { | ||
return isShellLanguage(language) ? ( | ||
<Terminal>{children}</Terminal> | ||
) : ( | ||
<CodeBlock language={language} {...props}> | ||
{children} | ||
</CodeBlock> | ||
); | ||
}; | ||
|
||
CustomCodeBlock.propTypes = CodeBlock.propTypes; | ||
|
||
export default CustomCodeBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters