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

const getPayload = require('./getPayload');
const createContext = require('./createContext');
const renderWithContext = require('./renderWithContext');

/**
 * 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;

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

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

    window.gitbookContext = context;

    // Render with the store
    const el = renderWithContext(context);

    ReactDOM.render(el, mountNode);
}


module.exports = bootstrap;