mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
closes #3505
This commit is contained in:
@@ -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(' ');
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user