diff options
Diffstat (limited to 'packages/gitbook-core/src/lib/bootstrap.js')
-rw-r--r-- | packages/gitbook-core/src/lib/bootstrap.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/gitbook-core/src/lib/bootstrap.js b/packages/gitbook-core/src/lib/bootstrap.js new file mode 100644 index 0000000..f3c99b7 --- /dev/null +++ b/packages/gitbook-core/src/lib/bootstrap.js @@ -0,0 +1,29 @@ +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). + * @param {Object} matching + */ +function bootstrap(matching) { + 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, matching); + + ReactDOM.render(el, mountNode); +} + + +module.exports = bootstrap; |