File tree Expand file tree Collapse file tree 2 files changed +22
-10
lines changed
css/components/0_utilities Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,6 @@ input[type="text"] {
2222 @apply p-4 mt-2 mb-2 bg-ThemeBeige block;
2323}
2424
25- .api-body pre code {
26- @apply p-2 mt-2 mb-4 bg-ThemeBeige block;
27- overflow-x : auto;
28- }
29-
30- .api-body code {
31- @apply p-1 bg-ThemeBeige;
32- }
33-
3425.api-desc code {
3526 @apply font-normal px-1 bg-ThemeTagGrey inline text-xs relative;
3627 padding-top : 4px ;
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import React from "react";
22// import PropTypes from "prop-types";
33import { graphql , StaticQuery } from "gatsby" ;
44import Markdown from "react-markdown/with-html" ;
5+ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" ;
6+ import { atomDark } from "react-syntax-highlighter/dist/esm/styles/prism" ;
57
68import Layout from "../../components/4_layouts/layout" ;
79import SEO from "../../components/0_utilities/seo" ;
@@ -27,6 +29,25 @@ const HeadingRenderer = props => {
2729 return < Heading { ...props } /> ;
2830} ;
2931
32+ class CodeBlock extends React . PureComponent {
33+ render ( ) {
34+ const { value } = this . props ;
35+
36+ return (
37+ < SyntaxHighlighter
38+ language = "shell"
39+ style = { atomDark }
40+ className = "api-samples"
41+ codeTagProps = { {
42+ style : { whiteSpace : "pre-wrap" }
43+ } }
44+ >
45+ { value }
46+ </ SyntaxHighlighter >
47+ ) ;
48+ }
49+ }
50+
3051class APIDocs extends React . Component {
3152 componentDidMount ( ) {
3253 window . addEventListener ( "scroll" , ( ) => {
@@ -58,7 +79,7 @@ class APIDocs extends React.Component {
5879 < Markdown
5980 source = { n . info . description }
6081 escapeHtml = { false }
61- renderers = { { heading : HeadingRenderer } }
82+ renderers = { { heading : HeadingRenderer , code : CodeBlock } }
6283 className = "md:mt-8 api-body"
6384 />
6485 </ div >
You can’t perform that action at this time.
0 commit comments