summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/bootstrap.js
blob: 0a2e9816005916be7bf3601bc3f9df2177ebed78 (plain)
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
const ReactDOM = require('react-dom');

const getPayload = require('./lib/getPayload');
const createStore = require('./createStore');
const renderWithStore = require('./renderWithStore');

/**
 * Bootstrap GitBook on the browser (this function should not be called on the server side)
 */
function bootstrap() {
    const initialState = getPayload(window.document);
    const plugins = window.gitbookPlugins;

    console.log(initialState);

    const mountNode = document.getElementById('content');

    // Create the redux store
    const store = createStore(plugins, initialState);

    window.appStore = store;

    // Render with the store
    const el = renderWithStore(store);

    ReactDOM.render(el, mountNode);
}


module.exports = bootstrap;