Also added fronmatter for interactive: true to turn on React on a file by file basis and prevent slowing down the builds for non-react files
22 lines
535 B
JavaScript
22 lines
535 B
JavaScript
const React = require('react')
|
|
const ReactDOM = require('react-dom')
|
|
|
|
const RedContent = (props) => {
|
|
return (
|
|
<div style={{ color: 'red' }}>
|
|
{props.children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (typeof window === 'undefined') {
|
|
} else {
|
|
const componentContainers = document.querySelectorAll('.react-component-RedContent')
|
|
|
|
for (const componentContainer of componentContainers) {
|
|
ReactDOM.render(React.createElement(RedContent, {}, componentContainer.children[0].innerText), componentContainer)
|
|
}
|
|
}
|
|
|
|
module.exports = RedContent
|