Server render auto-index pages

Also, load the autoIndex bundle on the client so we can use React
instead of using an inline script.
This commit is contained in:
Michael Jackson
2018-07-31 10:07:27 -07:00
parent 168ccf5aac
commit 135da0fdc5
62 changed files with 761 additions and 589 deletions

View File

@ -0,0 +1,5 @@
function getContentTypeHeader(type) {
return type === "application/javascript" ? type + "; charset=utf-8" : type;
}
module.exports = getContentTypeHeader;

View File

@ -4,11 +4,8 @@ const ReactDOMServer = require("react-dom/server");
const doctype = "<!DOCTYPE html>";
function renderPage(page, props) {
const html = ReactDOMServer.renderToStaticMarkup(
React.createElement(page, props)
);
return doctype + html;
const element = React.createElement(page, props);
return doctype + ReactDOMServer.renderToStaticMarkup(element);
}
module.exports = renderPage;