diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-08 18:19:49 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-08 18:19:49 +0200 |
commit | 03b89194d785807e12f3a7b40d5558d300e3cc49 (patch) | |
tree | bd63626c3186ce8699a473457127dd536bc0064a /packages/gitbook-core | |
parent | 68ec88c62096faf5c8538bec4431868919ae9652 (diff) | |
download | gitbook-03b89194d785807e12f3a7b40d5558d300e3cc49.zip gitbook-03b89194d785807e12f3a7b40d5558d300e3cc49.tar.gz gitbook-03b89194d785807e12f3a7b40d5558d300e3cc49.tar.bz2 |
Prepare for multiple role rendering for ebooks
Diffstat (limited to 'packages/gitbook-core')
-rw-r--r-- | packages/gitbook-core/src/lib/bootstrap.js | 7 | ||||
-rw-r--r-- | packages/gitbook-core/src/lib/renderWithContext.js | 12 |
2 files changed, 11 insertions, 8 deletions
diff --git a/packages/gitbook-core/src/lib/bootstrap.js b/packages/gitbook-core/src/lib/bootstrap.js index f5183d1..f3c99b7 100644 --- a/packages/gitbook-core/src/lib/bootstrap.js +++ b/packages/gitbook-core/src/lib/bootstrap.js @@ -5,9 +5,10 @@ const createContext = require('./createContext'); const renderWithContext = require('./renderWithContext'); /** - * Bootstrap GitBook on the browser (this function should not be called on the server side) + * Bootstrap GitBook on the browser (this function should not be called on the server side). + * @param {Object} matching */ -function bootstrap() { +function bootstrap(matching) { const initialState = getPayload(window.document); const plugins = window.gitbookPlugins; @@ -19,7 +20,7 @@ function bootstrap() { window.gitbookContext = context; // Render with the store - const el = renderWithContext(context); + const el = renderWithContext(context, matching); ReactDOM.render(el, mountNode); } diff --git a/packages/gitbook-core/src/lib/renderWithContext.js b/packages/gitbook-core/src/lib/renderWithContext.js index 44f8ba4..f9a093c 100644 --- a/packages/gitbook-core/src/lib/renderWithContext.js +++ b/packages/gitbook-core/src/lib/renderWithContext.js @@ -9,7 +9,8 @@ const contextShape = require('../shapes/context'); const GitBookApplication = React.createClass({ propTypes: { - context: contextShape + context: contextShape, + matching: React.PropTypes.object }, componentDidMount() { @@ -23,13 +24,13 @@ const GitBookApplication = React.createClass({ }, render() { - const { context } = this.props; + const { context, matching } = this.props; return ( <ContextProvider context={context}> <PJAXWrapper> <I18nProvider> - <InjectedComponent matching={{ role: 'Body' }} /> + <InjectedComponent matching={matching} /> </I18nProvider> </PJAXWrapper> </ContextProvider> @@ -42,11 +43,12 @@ const GitBookApplication = React.createClass({ * Render the application for a GitBook context. * * @param {GitBookContext} context + * @param {Object} matching * @return {React.Element} element */ -function renderWithContext(context) { +function renderWithContext(context, matching) { return ( - <GitBookApplication context={context} /> + <GitBookApplication context={context} matching={matching} /> ); } |