summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/renderComponent.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-09-05 14:02:49 +0200
committerSamy Pessé <samypesse@gmail.com>2016-09-05 14:02:49 +0200
commitff31514c669a7c9b04ee69c447dcf9e2da39f3da (patch)
treeb81b9bc9b12356dc1d9f7d8f8208be5631cc3d44 /packages/gitbook-core/src/renderComponent.js
parent3f1ec310ca0c634e1f63a1e00e485ea93916e810 (diff)
downloadgitbook-ff31514c669a7c9b04ee69c447dcf9e2da39f3da.zip
gitbook-ff31514c669a7c9b04ee69c447dcf9e2da39f3da.tar.gz
gitbook-ff31514c669a7c9b04ee69c447dcf9e2da39f3da.tar.bz2
Start bootstraping rendering with react in GitBook
Diffstat (limited to 'packages/gitbook-core/src/renderComponent.js')
-rw-r--r--packages/gitbook-core/src/renderComponent.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/gitbook-core/src/renderComponent.js b/packages/gitbook-core/src/renderComponent.js
new file mode 100644
index 0000000..365a037
--- /dev/null
+++ b/packages/gitbook-core/src/renderComponent.js
@@ -0,0 +1,25 @@
+const React = require('react');
+const Helmet = require('react-helmet');
+const ReactRedux = require('react-redux');
+const { InjectedComponent } = require('./components/InjectedComponent');
+
+/**
+ * Render a registered component from a store.
+ * This method is intended for server-side use in "gitbook".
+ *
+ * @param {ReduxStore} store
+ * @param {Descriptor} matching
+ * @return {Object} { el, meta }
+ */
+function renderComponent(store, matching) {
+ const el = (
+ <ReactRedux.Provider store={store}>
+ <InjectedComponent matching={matching} />
+ </ReactRedux.Provider>
+ );
+ const head = Helmet.rewind();
+
+ return { el, head };
+}
+
+module.exports = renderComponent;