Web: Doceditor: added server render
This commit is contained in:
parent
14490e8496
commit
f92d2dd2c5
@ -5,10 +5,7 @@ import { initDocEditor } from "./helpers/utils";
|
||||
|
||||
export default async (req) => {
|
||||
const props = await initDocEditor(req);
|
||||
const content = renderToString(<App />);
|
||||
|
||||
let content = renderToString(<App />);
|
||||
|
||||
// Get a copy of store data to create the same store on client side
|
||||
|
||||
return { app, content };
|
||||
return { props, content };
|
||||
};
|
||||
|
@ -1,26 +1,24 @@
|
||||
export default function template(title, initialState = {}, content = "") {
|
||||
let scripts = ""; // Dynamically ship scripts based on render type
|
||||
if (content) {
|
||||
scripts = ` <script>
|
||||
window.__STATE__ = ${JSON.stringify(initialState)}
|
||||
</script>
|
||||
<script src="/products/files/doceditor/static/scripts/doceditor.client.js"></script>
|
||||
`;
|
||||
} else {
|
||||
scripts = ` <script src="bundle.js"> </script> `;
|
||||
}
|
||||
let page = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title> ${title} </title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root">${content}</div>
|
||||
${scripts}
|
||||
</body>
|
||||
`;
|
||||
const scripts = `
|
||||
<script>
|
||||
window.__STATE__ = ${JSON.stringify(initialState)}
|
||||
</script>
|
||||
<script src="/products/files/doceditor/static/scripts/doceditor.client.js"></script>
|
||||
`;
|
||||
|
||||
const page = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title> ${title} </title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root">${content}</div>
|
||||
${scripts}
|
||||
</body>
|
||||
`;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user