-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_ssr.js
39 lines (34 loc) · 1.08 KB
/
main_ssr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React from 'react'
import { renderToString } from 'react-dom/server'
import Card from './src/js/card.jsx'
global.window = {};
// function getScriptString(mode, dataJSON, selector, site_configs) {
// return `<script>
// var x = new ProtoGraph.Card.toStory(),
// params = {
// "selector": document.querySelector('${selector}'),
// "isFromSSR": true,
// "initialState": ${JSON.stringify(dataJSON)},
// "site_configs": ${JSON.stringify(site_configs)}
// };
// x.init(params);
// x.render();
// </script>
// `
// }
function render(initialState) {
console.log("Cover image Initial state: ", initialState);
let content = renderToString(
<Card
dataJSON={initialState.dataJSON}
mode={initialState.mode}
renderingSSR={true}
/>
);
return { content, initialState };
}
module.exports = {
render: render,
// getScriptString: getScriptString,
instance: 'toCoverImage'
}