Gatsby setup for API docs
This commit is contained in:
26
site/components/Code.js
Normal file
26
site/components/Code.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import React, {PureComponent} from 'react';
|
||||
import {string} from 'prop-types';
|
||||
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter';
|
||||
import {coy} from 'react-syntax-highlighter/dist/styles/prism';
|
||||
|
||||
class Code extends PureComponent {
|
||||
render() {
|
||||
let language = this.props.language;
|
||||
if (!language) {
|
||||
language = 'js';
|
||||
}
|
||||
|
||||
return (
|
||||
<SyntaxHighlighter language={language} style={coy}>
|
||||
{this.props.value}
|
||||
</SyntaxHighlighter>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Code.propTypes = {
|
||||
value: string.isRequired,
|
||||
language: string
|
||||
};
|
||||
|
||||
export default Code;
|
||||
Reference in New Issue
Block a user