this package now works for custom pages
This commit is contained in:
parent
d0c13dafdc
commit
e230ff95d1
4 changed files with 22 additions and 4217 deletions
4207
index.js
4207
index.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,11 +5,11 @@ import { Provider } from 'react-redux';
|
||||||
import { StaticRouter } from 'react-router-dom';
|
import { StaticRouter } from 'react-router-dom';
|
||||||
import { Reducers, GAListener, App } from 'spee.ch-components';
|
import { Reducers, GAListener, App } from 'spee.ch-components';
|
||||||
/*
|
/*
|
||||||
^ note: to do this better, maybe
|
^ note: to do this right, maybe
|
||||||
these should be passed in from the implementation (www.spee.ch)
|
these should be passed in from the implementation (www.spee.ch) itself,
|
||||||
after they have been customized,
|
so that there are no conflicts between the SSR here and
|
||||||
so that there is no conflict between the SSR here and
|
|
||||||
the bundle sent to the server?
|
the bundle sent to the server?
|
||||||
|
there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?
|
||||||
*/
|
*/
|
||||||
import renderFullPage from './renderFullPage.js';
|
import renderFullPage from './renderFullPage.js';
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
|
@ -20,17 +20,18 @@ module.exports = (req, res) => {
|
||||||
let context = {};
|
let context = {};
|
||||||
|
|
||||||
// customize the reducer by passing in intial state configs
|
// customize the reducer by passing in intial state configs
|
||||||
const customizedReducers = Reducers(siteConfig);
|
const CustomizedReducers = Reducers(siteConfig);
|
||||||
|
const CustomizedApp = App(siteConfig);
|
||||||
|
|
||||||
// create a new Redux store instance
|
// create a new Redux store instance
|
||||||
const store = createStore(customizedReducers);
|
const store = createStore(CustomizedReducers);
|
||||||
|
|
||||||
// render component to a string
|
// render component to a string
|
||||||
const html = renderToString(
|
const html = renderToString(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<StaticRouter location={req.url} context={context}>
|
<StaticRouter location={req.url} context={context}>
|
||||||
<GAListener>
|
<GAListener>
|
||||||
<App />
|
<CustomizedApp />
|
||||||
</GAListener>
|
</GAListener>
|
||||||
</StaticRouter>
|
</StaticRouter>
|
||||||
</Provider>
|
</Provider>
|
||||||
|
|
|
@ -7,12 +7,19 @@ import renderFullPage from './renderFullPage';
|
||||||
import createSagaMiddleware from 'redux-saga';
|
import createSagaMiddleware from 'redux-saga';
|
||||||
import { call } from 'redux-saga/effects';
|
import { call } from 'redux-saga/effects';
|
||||||
import { Reducers, GAListener, App, Sagas, Actions } from 'spee.ch-components';
|
import { Reducers, GAListener, App, Sagas, Actions } from 'spee.ch-components';
|
||||||
|
/*
|
||||||
|
^ note: to do this right, maybe
|
||||||
|
these should be passed in from the implementation (www.spee.ch) itself,
|
||||||
|
so that there are no conflicts between the SSR here and
|
||||||
|
the bundle sent to the server?
|
||||||
|
there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?
|
||||||
|
*/
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
|
|
||||||
// configure the reducers by passing initial state configs
|
// configure the reducers by passing initial state configs
|
||||||
const siteConfig = require('siteConfig.js');
|
const siteConfig = require('siteConfig.js');
|
||||||
const customizedReducers = Reducers(siteConfig);
|
const CustomizedReducers = Reducers(siteConfig);
|
||||||
|
const CustomizedApp = App(siteConfig);
|
||||||
|
|
||||||
const returnSagaWithParams = (saga, params) => {
|
const returnSagaWithParams = (saga, params) => {
|
||||||
return function * () {
|
return function * () {
|
||||||
|
@ -28,7 +35,7 @@ module.exports = (req, res) => {
|
||||||
const middleware = applyMiddleware(sagaMiddleware);
|
const middleware = applyMiddleware(sagaMiddleware);
|
||||||
|
|
||||||
// create a new Redux store instance
|
// create a new Redux store instance
|
||||||
const store = createStore(customizedReducers, middleware);
|
const store = createStore(CustomizedReducers, middleware);
|
||||||
|
|
||||||
// create saga
|
// create saga
|
||||||
const action = Actions.onHandleShowPageUri(req.params);
|
const action = Actions.onHandleShowPageUri(req.params);
|
||||||
|
@ -44,7 +51,7 @@ module.exports = (req, res) => {
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<StaticRouter location={req.url} context={context}>
|
<StaticRouter location={req.url} context={context}>
|
||||||
<GAListener>
|
<GAListener>
|
||||||
<App />
|
<CustomizedApp />
|
||||||
</GAListener>
|
</GAListener>
|
||||||
</StaticRouter>
|
</StaticRouter>
|
||||||
</Provider>
|
</Provider>
|
||||||
|
|
Loading…
Reference in a new issue