summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/bootstrap.js
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-09-22 09:54:24 +0200
committerSamy Pesse <samypesse@gmail.com>2016-09-22 09:54:24 +0200
commit0b1888e184d3f995c3130daf794416ad0a4312bc (patch)
treeb22af323c65ad0e4d458ff6ab85bad00b5a39ba8 /packages/gitbook-core/src/bootstrap.js
parent2257e42299f28f2a276bf2febd7f5d00e3931c08 (diff)
downloadgitbook-0b1888e184d3f995c3130daf794416ad0a4312bc.zip
gitbook-0b1888e184d3f995c3130daf794416ad0a4312bc.tar.gz
gitbook-0b1888e184d3f995c3130daf794416ad0a4312bc.tar.bz2
First working version in the browser
Diffstat (limited to 'packages/gitbook-core/src/bootstrap.js')
-rw-r--r--packages/gitbook-core/src/bootstrap.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/gitbook-core/src/bootstrap.js b/packages/gitbook-core/src/bootstrap.js
new file mode 100644
index 0000000..a5b457b
--- /dev/null
+++ b/packages/gitbook-core/src/bootstrap.js
@@ -0,0 +1,28 @@
+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;
+
+ 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;