This commit is contained in:
barisusakli
2015-10-16 18:43:40 -04:00
parent e60c1d8736
commit f2d6f931af
3 changed files with 16 additions and 1 deletions

View File

@@ -29,6 +29,8 @@ module.exports = function(middleware) {
options.relative_path = nconf.get('relative_path');
options.template = {name: template};
options.template[template] = true;
options.bodyClass = buildBodyClass(req);
res.locals.template = template;
if (res.locals.isAPI) {
@@ -80,4 +82,14 @@ module.exports = function(middleware) {
next();
};
function buildBodyClass(req) {
var clean = req.path.replace(/^\/api/, '').replace(/^\//, '');
var parts = clean.split('/').slice(0, 3);
parts.forEach(function(p, index) {
parts[index] = index ? parts[index - 1] + '-' + p : 'page-' + (p || 'home');
});
return parts.join(' ');
}
};