React Static Site
braddenver.com
braddenver.com
The experience has been fantastic compared to other static site generators (very limited control over display of content) or CMSes (too indirect for what is basically simple logic, especially around internationalization).
It was a bit fiddly getting everything set up so that React, React Router, React Intl, and Static Site Generator all played nicely together. But after about a day of banging my head on that, it's just worked ever since and been a dream.
If I could ask for one improvement: right now the build first runs the code through Babel and then runs that through WebPack. Problem is, if parts of the Babel build fail, there's no error reporting, and instead I get a WebPack-stage error about some file not being available. I then have to manually run the file through Babel to see that there's a simple syntax error.
[0] https://github.com/markdalgleish/static-site-generator-webpa...
I'm not sure if this is the same problem you've encountered, but if you find a solution I'm definitely interested. :)
https://github.com/gaearon/react-dnd/blob/master/scripts/bui...
The hard part might be routing, since there doesn't seem to be a robust solution for doing that in Reagent yet. I found https://github.com/ghedamat/reagent-react-router but it hasn't been updated in months and the author calls it "very very alpha."
[1] https://github.com/Day8/re-frame and https://github.com/Day8/re-frame-template
You'll have to do `lein new re-frame <project> +routes` to pull in the routing template.
https://github.com/facebook/react-native/tree/master/website...
It seems (to me), that it would be useful--in addition to the static html--load React on the client and from that point navigate with push state and small static (JSON?) files. It might perform better if your blog has a lot more interactivity. Although, here I can definitely see that as being fluff.
A harder fix is to walk the static DOM to inflate your store. It shouldn't be too hard since you can add hints to the DOM to guide your parser.
A useful pattern I discovered was fetching just what is necessary to render the page on the server. Then pass the state to the window object through a script tag and recover the data on the client side and rehydrate. Any additional data (or potentially slow returning), I fetch client side via `componentDidMount` [0] which isn't called on the server. This way, I can get a loading screen up as quickly as possible with a few elements custom to the user.
I should note that even thought the flux library I was using, flummox [1], works great for this, I can't recommend it as in the month and a half I was working on my project they've decided to quit and recommend a different library, so I'm not sure what to recommend now (the frustration I feel over this quick turnaround is an entirely separate topic, though).
0: https://facebook.github.io/react/docs/component-specs.html#m...
1: http://acdlite.github.io/flummox
2: https://github.com/acdlite/flummox#40-will-likely-be-the-las...
To the original point, you are still sending the data twice, once in rendered html, and once in that state that gets rehydrated.
The entire rendered source is 142K. I isolated the actual markup, and it weighs in at 31K.
In other words, your dehydrated state is 4x bigger than your html rendering. And that's not including your 750K main.js file that also gets downloaded.
That's almost 1MB of downloads (not including images and stylesheets) just to "app-ify" your 31K of markup. I tend to agree, it's not a problem. Or perhaps, it's not one of the biggest problems. But it's not "hardly an issue" either.
You just have to memorize a few command to publish stuff.
Also of course, know Markdown.
Likewise with PHP and wordpress or Node.js and Ghost.
I've used Jeykl and Octopress and a few others. I dislike having to install random libraries just to get simple blog to render properly.
Go-lang built tools (like the free and excellent Hugo - https://gohugo.io/) are single binaries. Just get the one that works on your platform.
Blogging 101: If you write petty, snarky comments about millions of other developers, people will focus on those rather than the content of your post.
+ return (
+ <html>
+ <head>
+ <title>{this.props.title}</title>
+ </head>
+ <body>
+ {this.props.children}
+ {script}
+ </body>
+ </html>
+ );
https://github.com/jlongster/blog/blob/master/src/components...https://www.reddit.com/r/javascript/comments/2uvz0x/whats_so...
However, i dove into web components with Polymer, and it seems that this is the "official" direction of components in the future web... It also doesnt try to mix HTML with JavaScript. In fact in the future there will be more langauges than javascript since there will be a bytecode for the browser. Having your app written in React poses a real problem when you want to switch your logic to a different programming language.
So isnt the Web Components solution much better?
It seems that React and Web Components can be combined: https://github.com/Wildhoney/Maple.js
And you don't have to with React. But you can do this kind of mess with any templating langauge - it's not a React issue, it's a bad programming issue.
> Having your app written in React poses a real problem when you want to switch your logic to a different programming language.
It really shouldn't. It's a View layer and the JSX part will be (practically) HTML still so it'll be really easy to port. The rest of the view logic would have to be ported no-matter what you use to decorate it.
So this isn't really an objection.
The issue is that the pattern for a long time has been even worse, making your logic deal with your presentation directly.
When you're building an application, something like the atom text editor, or the youtube video player — something interactive and ostensibly not a document — the segregation of markup and javascript is artificial. Yes, it's a good idea to keep your presentation separate from your logic (although religious devotion to this idea is unnecessary, it's just an abstraction that's useful has stood the test of time, not holy law), but your javascript view code is just as much a part of the presentation as the markup.
In response to a sibling comment, you claim "you dont want to mix the 'structure' of your UI with the behaviour". The fact that your views have a "structure" to begin with is again an artifact of the web's original intention of hosting documents rather than applications. The structure of your view is actually an implementation detail (a concept that's formalized by the Shadow DOM standard in the WebComponents proposal), and separating it out from your view code implies otherwise.
If you're also against things like Handlebars, ERB, Smarty, etc then fine... but otherwise this doesn't hold up.
Why? Because all template languages must be compiled to the host language to work. Handlebars ends up as JS functions (and really ugly and messy ones I might add) for example.
This is fine if, for some reason, you're in 2001 and handing off all templating to designers who know nothing about code and just have to put HTML in a template with the right variables... but it's a very very janky practice.
JSX just says "well, why bother when you can do it in the right place in the first place?" Template languages have logic so why not just use JS and correctly encapsulate the logic in a View?
Answer? No good reason to not do that... so it's a net win.