mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
feat: add parent cids to body class
This commit is contained in:
@@ -122,6 +122,7 @@ async function buildBreadcrumbs(req, categoryData) {
|
|||||||
{
|
{
|
||||||
text: categoryData.name,
|
text: categoryData.name,
|
||||||
url: nconf.get('relative_path') + '/category/' + categoryData.slug,
|
url: nconf.get('relative_path') + '/category/' + categoryData.slug,
|
||||||
|
cid: categoryData.cid,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const crumbs = await helpers.buildCategoryBreadcrumbs(categoryData.parentCid);
|
const crumbs = await helpers.buildCategoryBreadcrumbs(categoryData.parentCid);
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ helpers.buildCategoryBreadcrumbs = async function (cid) {
|
|||||||
breadcrumbs.unshift({
|
breadcrumbs.unshift({
|
||||||
text: String(data.name),
|
text: String(data.name),
|
||||||
url: nconf.get('relative_path') + '/category/' + data.slug,
|
url: nconf.get('relative_path') + '/category/' + data.slug,
|
||||||
|
cid: cid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
cid = data.parentCid;
|
cid = data.parentCid;
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ async function buildBreadcrumbs(topicData) {
|
|||||||
{
|
{
|
||||||
text: topicData.category.name,
|
text: topicData.category.name,
|
||||||
url: nconf.get('relative_path') + '/category/' + topicData.category.slug,
|
url: nconf.get('relative_path') + '/category/' + topicData.category.slug,
|
||||||
|
cid: topicData.category.cid,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: topicData.title,
|
text: topicData.title,
|
||||||
|
|||||||
@@ -127,6 +127,13 @@ module.exports = function (middleware) {
|
|||||||
parts.push('page-topic-category-' + templateData.category.cid);
|
parts.push('page-topic-category-' + templateData.category.cid);
|
||||||
parts.push('page-topic-category-' + utils.slugify(templateData.category.name));
|
parts.push('page-topic-category-' + utils.slugify(templateData.category.name));
|
||||||
}
|
}
|
||||||
|
if (templateData.breadcrumbs) {
|
||||||
|
templateData.breadcrumbs.forEach(function (crumb) {
|
||||||
|
if (crumb.hasOwnProperty('cid')) {
|
||||||
|
parts.push('parent-category-' + crumb.cid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
parts.push('page-status-' + res.statusCode);
|
parts.push('page-status-' + res.statusCode);
|
||||||
return parts.join(' ');
|
return parts.join(' ');
|
||||||
|
|||||||
Reference in New Issue
Block a user