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:
5
server/utils/getContentTypeHeader.js
Normal file
5
server/utils/getContentTypeHeader.js
Normal file
@ -0,0 +1,5 @@
|
||||
function getContentTypeHeader(type) {
|
||||
return type === "application/javascript" ? type + "; charset=utf-8" : type;
|
||||
}
|
||||
|
||||
module.exports = getContentTypeHeader;
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user