docusaurus/lib/core/Remarkable.js
Tom Auger 2d7274f6fe Blog feed fixes #370 (#407)
* Refactor markdown rendering into separate module

* Render blog feed description in html
2018-02-11 08:05:58 -08:00

42 lines
868 B
JavaScript

'use strict';
const React = require('react');
const renderMarkdown = require('./renderMarkdown.js');
const CWD = process.cwd();
class Remarkable extends React.Component {
content() {
if (this.props.source) {
return (
<span
dangerouslySetInnerHTML={{
__html: renderMarkdown(this.props.source),
}}
/>
);
} else {
return React.Children.map(this.props.children, child => {
if (typeof child === 'string') {
return (
<span dangerouslySetInnerHTML={{__html: renderMarkdown(child)}} />
);
} else {
return child;
}
});
}
}
render() {
var Container = this.props.container;
return <Container>{this.content()}</Container>;
}
}
Remarkable.defaultProps = {
container: 'div',
};
module.exports = Remarkable;