Node.js based forum software built for the modern web
refactor: update buildCategoryLabel
Barış Soner Uşaklı82ea91920ada
diff --git a/public/src/modules/helpers.common.js b/public/src/modules/helpers.common.jsindex 00b6a3fe74..07ab724963 100644--- a/public/src/modules/helpers.common.js+++ b/public/src/modules/helpers.common.js@@ -97,15 +97,16 @@ module.exports = function (utils, Benchpress, relative_path) {return `<span class="icon d-inline-flex justify-content-center align-items-center align-middle ${rounded}" style="${generateCategoryBackground(category)} width:${size}; height: ${size}; font-size: ${parseInt(size, 10) / 2}px;">${category.icon ? `<i class="fa fa-fw ${category.icon}"></i>` : ''}</span>`;}- function buildCategoryLabel(category, className = '') {+ function buildCategoryLabel(category, tag = 'a', className = '') {if (!category) {return '';}- return `<span class="badge px-1 ${className} text-truncate" style="color: ${category.color};background-color: ${category.bgColor};border-color: ${category.bgColor}!important; max-width: 70vw;">+ const href = tag === 'a' ? `href="${relative_path}/category/${category.slug}"` : '';+ return `<${tag} ${href} class="badge px-1 text-truncate text-decoration-none ${className}" style="color: ${category.color};background-color: ${category.bgColor};border-color: ${category.bgColor}!important; max-width: 70vw;">${category.icon && category.icon !== 'fa-nbb-none' ? `<i class="fa fa-fw ${category.icon}"></i>` : ''}${category.name}- </span>`;+ </${tag}>`;}function generateCategoryBackground(category) {