File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,9 @@ const bundles = [
16
16
'/index.bundle.js'
17
17
] ;
18
18
19
+ // TODO: Use a `walk` utility from `directory-tree-webpack-plugin`
19
20
const Content = require ( './_content.json' ) ;
20
-
21
- const paths = Content . children . reduce ( ( paths , page ) => {
21
+ const pathsToTitles = Content . children . reduce ( ( paths , page ) => {
22
22
if ( page . type === 'directory' ) {
23
23
page . children . forEach ( child => ( paths [ child . url ] = child . title ) ) ;
24
24
} else {
@@ -35,7 +35,17 @@ const paths = Content.children.reduce((paths, page) => {
35
35
// description, etc).
36
36
export default locals => {
37
37
let { assets } = locals . webpackStats . compilation ;
38
- let title = paths [ locals . path ] === 'webpack' ? paths [ locals . path ] : `${ paths [ locals . path ] } | webpack` ;
38
+ let title ;
39
+
40
+ if ( locals . path === '/' ) {
41
+ title = pathsToTitles [ locals . path ] ;
42
+
43
+ } else if ( ! pathsToTitles [ locals . path ] ) {
44
+ if ( ! locals . path . endsWith ( '/' ) ) locals . path += '/' ;
45
+ title = locals . path . replace ( / .* \/ ( .+ ) \/ / g, '$1' ) ;
46
+ title = title . replace ( / - / g, ' ' ) ;
47
+
48
+ } else title = `${ pathsToTitles [ locals . path ] } | webpack` ;
39
49
40
50
return ReactDOMServer . renderToString (
41
51
< StaticRouter location = { locals . path } context = { { } } >
You can’t perform that action at this time.
0 commit comments