Skip to content

Commit 70379d5

Browse files
committed
chore: Fix titles
Now there should be titles everywhere. It either parses a possible title from a Markdown file or uses one from a layout. I pushed those to the configuration so you have a single place where to manage them.
1 parent 1c703cf commit 70379d5

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

antwar.config.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ const combineContexts = require('./utilities/combine-contexts');
55
module.exports = {
66
maximumWorkers: process.env.TRAVIS && 1, // Faster on Travis
77
template: {
8-
title: 'webpack',
9-
description: 'webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.',
108
file: path.join(__dirname, 'template.ejs')
119
},
1210
output: 'build',
@@ -22,7 +20,14 @@ module.exports = {
2220
/^\.\/.*\.md$/
2321
)
2422
),
25-
index: () => require('./components/splash/splash.jsx').default,
23+
index: () => {
24+
const index = require('./components/splash/splash.jsx').default;
25+
26+
index.title = 'webpack';
27+
index.description = 'webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.';
28+
29+
return index;
30+
},
2631
layout: () => require('./components/page/page.jsx').default,
2732
paths: {
2833
'get-started': {
@@ -91,8 +96,26 @@ module.exports = {
9196
}
9297
}
9398
},
94-
vote: () => require('./components/vote/list.jsx').default,
95-
organization: () => require('./components/organization/organization.jsx').default,
96-
'guides/starter-kits': () => require('./components/starter-kits/starter-kits.jsx').default
99+
vote: () => {
100+
const page = require('./components/vote/list.jsx').default;
101+
102+
page.title = 'Vote';
103+
104+
return page;
105+
},
106+
organization: () => {
107+
const page = require('./components/organization/organization.jsx').default;
108+
109+
page.title = 'Organization';
110+
111+
return page;
112+
},
113+
'guides/starter-kits': () => {
114+
const page = require('./components/starter-kits/starter-kits.jsx').default;
115+
116+
page.title = 'Starter kits';
117+
118+
return page;
119+
}
97120
}
98121
};

loaders/page-loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = function (source) {
1111
result.attributes.anchors = markdown().getAnchors(result.body);
1212
result.attributes.contributors = (result.attributes.contributors || []).sort();
1313
result.attributes.related = Array.isArray(result.attributes.related) ? result.attributes.related : [];
14+
result.title = result.attributes.title || 'webpack';
1415
result.body = markdown().process(result.body, highlight);
1516

1617
delete result.frontmatter;

0 commit comments

Comments
 (0)