Skip to content

Commit

Permalink
Load SEO metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
munirajun committed Sep 5, 2017
1 parent 5297fed commit 0c6d954
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions server/handlers/isomorphic-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,20 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(req, res, {config
const match = matchBestRoute(url.pathname, generateRoutes(config));
if(match) {
return fetchData(loadData, loadErrorData, match.pageType, match.params, config)
.then((result) => {
const store = createStore((state) => state, result);
renderLayout(res.status(result.httpStatusCode || 200), {
content: ReactDOMServer.renderToString(
React.createElement(Provider, {store: store},
React.createElement(IsomorphicComponent, {pickComponent: pickComponent})))
});
.then((result) => {
const store = createStore(
(state) => state,
{pageType : result.pageType, data : result.data, config : result.config}
);

renderLayout(res.status(result.httpStatusCode || 200), {
metadata: loadSeoData(config, result.pageType, result.data),
content: ReactDOMServer.renderToString(
React.createElement(Provider, {store: store},
React.createElement(IsomorphicComponent, {pickComponent: pickComponent}))
)
});
});
} else {
renderLayout(res.status(404), {
content: "Not Found"
Expand Down

0 comments on commit 0c6d954

Please sign in to comment.