Make the publish script faster by not converting all the files on every file

This commit is contained in:
Christopher Chedeau 2015-03-15 19:54:14 -07:00
parent ad3192c360
commit 591d7b321f
4 changed files with 12 additions and 8 deletions

View File

@ -9,10 +9,9 @@ var slugify = require('slugify');
var Header = React.createClass({ var Header = React.createClass({
render: function() { render: function() {
var slug = slugify(this.props.toSlug || this.props.children); var slug = slugify(this.props.toSlug || this.props.children);
var H = React.DOM['h' + this.props.level]; var H = 'h' + this.props.level;
return (
return this.transferPropsTo( <H {...this.props}>
<H>
<a className="anchor" name={slug}></a> <a className="anchor" name={slug}></a>
{this.props.children} {this.props.children}
{' '}<a className="hash-link" href={'#' + slug}>#</a> {' '}<a className="hash-link" href={'#' + slug}>#</a>

View File

@ -7,8 +7,10 @@ var React = require('React');
var center = React.createClass({ var center = React.createClass({
render: function() { render: function() {
return this.transferPropsTo( return (
<div style={{textAlign: 'center'}}>{this.props.children}</div> <div {...this.props} style={{textAlign: 'center'}}>
{this.props.children}
</div>
); );
} }
}); });

View File

@ -6,6 +6,7 @@ var mkdirp = require('mkdirp');
var server = require('./server.js'); var server = require('./server.js');
require('./convert.js')(); require('./convert.js')();
server.noconvert = true;
// Sadly, our setup fatals when doing multiple concurrent requests // Sadly, our setup fatals when doing multiple concurrent requests
// I don't have the time to dig into why, it's easier to just serialize // I don't have the time to dig into why, it's easier to just serialize

View File

@ -36,7 +36,9 @@ var app = connect()
.use(function(req, res, next) { .use(function(req, res, next) {
// convert all the md files on every request. This is not optimal // convert all the md files on every request. This is not optimal
// but fast enough that we don't really need to care right now. // but fast enough that we don't really need to care right now.
if (!server.noconvert) {
convert(); convert();
}
next(); next();
}) })
.use(reactMiddleware.provide(buildOptions)) .use(reactMiddleware.provide(buildOptions))
@ -49,5 +51,5 @@ var app = connect()
var portToUse = port || 8080; var portToUse = port || 8080;
var server = http.createServer(app); var server = http.createServer(app);
server.listen(portToUse); server.listen(portToUse);
console.log('Open http://localhost:' + portToUse + '/react-native/index.html'); console.log('Open http://localhost:' + portToUse + '/react-native/_index.html');
module.exports = server; module.exports = server;