mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
closes #6140
This commit is contained in:
@@ -8,6 +8,7 @@ var winston = require('winston');
|
||||
var plugins = require('../plugins');
|
||||
var translator = require('../translator');
|
||||
var widgets = require('../widgets');
|
||||
var utils = require('../utils');
|
||||
|
||||
module.exports = function (middleware) {
|
||||
middleware.processRender = function (req, res, next) {
|
||||
@@ -40,7 +41,7 @@ module.exports = function (middleware) {
|
||||
options.template = { name: template };
|
||||
options.template[template] = true;
|
||||
options.url = (req.baseUrl + req.path.replace(/^\/api/, ''));
|
||||
options.bodyClass = buildBodyClass(req);
|
||||
options.bodyClass = buildBodyClass(req, options);
|
||||
|
||||
plugins.fireHook('filter:' + template + '.build', { req: req, res: res, templateData: options }, next);
|
||||
},
|
||||
@@ -125,7 +126,7 @@ module.exports = function (middleware) {
|
||||
});
|
||||
}
|
||||
|
||||
function buildBodyClass(req) {
|
||||
function buildBodyClass(req, templateData) {
|
||||
var clean = req.path.replace(/^\/api/, '').replace(/^\/|\/$/g, '');
|
||||
var parts = clean.split('/').slice(0, 3);
|
||||
parts.forEach(function (p, index) {
|
||||
@@ -138,6 +139,12 @@ module.exports = function (middleware) {
|
||||
p = validator.escape(String(p));
|
||||
parts[index] = index ? parts[0] + '-' + p : 'page-' + (p || 'home');
|
||||
});
|
||||
|
||||
if (templateData.template.topic) {
|
||||
parts.push('page-topic-category-' + templateData.category.cid);
|
||||
parts.push('page-topic-category-' + utils.slugify(templateData.category.name));
|
||||
}
|
||||
|
||||
return parts.join(' ');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user