Metalsmith Static Site Generator (with React Jsx)

- 1 answer

I really want to create static site generator using reacts jsx templates/components. Jekyll and middleman had to be hacked to allow this...

But I've discovered with plugin:

I've following so far:

var Metalsmith    = require('metalsmith');
var reactTemplate = require('metalsmith-react-templates');

    directory: 'templates',
    isStatic: true
  .build(function(err) {
    if (err) throw err;

and jsx file:

var React = require('react');

var Entry = React.createClass({
  render: function() {

    return ();

module.exports = Entry;

when I run node build.js it errors out:

entry.jsx: Unexpected token

enter image description here

metalsmith-react-templates example seems to be outdated hence the problems?

Tried suggestion @:

  4 |   render: function() {
  5 | 
> 6 |     return (<p>Entry</p>);
    |             ^
  7 |   }
  8 | });
  9 | 



If you're still having issues even after doing return (<p>Entry</p>);, it is highly possible that it's actually an issue from the babel compiler.

What version of babel are you using?

If it's version 6 and above, check that you've at least installed the babel-preset-react and the babel-preset-es2015 plugins.