mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 02:37:59 +02:00
* Refactor markdown rendering into separate module * Render blog feed description in html
42 lines
868 B
JavaScript
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;
|