Lay client out a bit better
This commit is contained in:
parent
08e0aa7665
commit
0b00b190fc
5 changed files with 191 additions and 26 deletions
19
routes/index.js
Normal file
19
routes/index.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
var React = require('react');
|
||||
var nodejsx = require('node-jsx').install({extension: '.jsx'});
|
||||
var Home = React.createFactory(require('../client/index.jsx').Home);
|
||||
|
||||
module.exports = function(req, res, next) {
|
||||
|
||||
req.db.matches.find().sort({created_at:-1}).limit(6).toArray().then(function(docs){
|
||||
var recent = [];
|
||||
docs.forEach(function(doc) {
|
||||
recent.push(doc.services[doc._id.split("$$")[0]]);
|
||||
})
|
||||
|
||||
var home = Home({recent: recent});
|
||||
res.send('<!doctype html>\n' + React.renderToString(home).replace("</body></html>", "<script>var recent = " + JSON.stringify(recent) + "</script></body></html>"));
|
||||
//res.render('index', { page: "home", recent: docs, error: req.flash('search-error') });
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue