From 5160ea7f5839c91ef41ae211bb25a1934a7aea08 Mon Sep 17 00:00:00 2001 From: Fernando Montoya Date: Tue, 27 Mar 2018 17:30:58 +0200 Subject: [PATCH 1/7] chore(site): Add page title to server render - Created a simple hash object to save paths and page titles - Use previous object for SSGPlugin since crawl wasn't working, it fails to collect all links ignoring 'configuration' section entirely. --- src/server.jsx | 38 ++++++++++++++++++-------------------- webpack.prod.js | 22 ++++++++++++++++++++-- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/server.jsx b/src/server.jsx index 035baa9e8b1d..1374ca4028e9 100644 --- a/src/server.jsx +++ b/src/server.jsx @@ -11,42 +11,40 @@ import Favicon from './favicon.ico'; // Define bundles (previously used `Object.values(locals.assets)`) but // can't retrieve from there anymore due to separate compilation. -const bundles = [ - '/vendor.bundle.js', - '/index.bundle.js' -]; +const bundles = ['/vendor.bundle.js', '/index.bundle.js']; // Export method for `SSGPlugin` export default locals => { let { assets } = locals.webpackStats.compilation; + let title = locals.paths[locals.path]; return ReactDOMServer.renderToString( - + - + - {/* TODO */} | webpack - - - { Object.keys(assets).filter(asset => /\.css$/.test(asset)).map(path => ( - - ))} + {title} | webpack + + + {Object.keys(assets) + .filter(asset => /\.css$/.test(asset)) + .map(path => )}
( - require(`./content/${path}`) } /> - )} /> + render={props => ( + require(`./content/${path}`)} /> + )} + />
- { bundles.map(path => ( -