Open erisnuts opened 7 years ago
You may just need to add the following to index.js. Could you try it out?
hexo.extend.renderer.register('js', 'html', renderer, true)
I'm a little nervous about assuming every .js
file is a react component, though.
yes, it works, thank you!
hexo-renderer-react/index.js
hexo.extend.renderer.register('js', 'html', function (data, locals) {
var js = babel.transform(data.text, { filename: data.path })
var Component = reval(js.code, data.path, null, true)
var element = React.createElement(Component.default || Component, locals)
var markup = ReactDOMServer.renderToStaticMarkup(element);
if(markup.match(/^<html/)) {
markup = '<!doctype html>' + markup;
}
return markup;
}, true)
If I making js instead of jsx renderer dosen't work. But if I renaming the file - works perfectly. I am not using JSX so I want make js files. Help, please.