Adding a hack to allow setting page titles

I may look for a more robust system to handle markup than just gulp-wrap
This commit is contained in:
Jeff Avallone 2014-12-21 01:42:48 -05:00
parent 82ca4f40f7
commit 12a4186188
3 changed files with 16 additions and 3 deletions

View File

@ -5,6 +5,11 @@ var path = require('path'),
buildPath = _.bind(path.join, path, buildRoot); buildPath = _.bind(path.join, path, buildRoot);
module.exports = { module.exports = {
titles: {
'_': 'Regexper',
'changelog.html': 'Regexper - Changelog',
'documentation.html': 'Regexper - Documentation'
},
buildRoot: buildRoot, buildRoot: buildRoot,
buildPath: buildPath, buildPath: buildPath,
templateFile: './template.html', templateFile: './template.html',

View File

@ -38,11 +38,19 @@ gulp.task('static', function() {
}); });
gulp.task('markup', function() { gulp.task('markup', function() {
var wrap = require('gulp-wrap'); var wrap = require('gulp-wrap'),
path = require('path');
return gulp.src(config.globs.html, { base: './src' }) return gulp.src(config.globs.html, { base: './src' })
.pipe(errorHandler()) .pipe(errorHandler())
.pipe(wrap({ src: config.templateFile })) .pipe(wrap({ src: config.templateFile }, {
title: function() {
var root = path.join(this.file.cwd, this.file.base),
file = path.relative(root, this.file.history[0]);
return config.titles[file] || config.titles['_'];
}
}))
.pipe(gulp.dest(config.buildRoot)); .pipe(gulp.dest(config.buildRoot));
}); });

View File

@ -4,7 +4,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Regexper</title> <title>${title()}</title>
<meta name="description" content="Regular expression visualizer using railroad diagrams" /> <meta name="description" content="Regular expression visualizer using railroad diagrams" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />