Fix categoryColor for /categories view

Fix categoryColor for /categories view

And accept both categoryColor and categoryColour as special params.

diff --git a/javascripts/discourse/initializers/category-icons.js b/javascripts/discourse/initializers/category-icons.js
index 7875070..a5d87db 100644
--- a/javascripts/discourse/initializers/category-icons.js
+++ b/javascripts/discourse/initializers/category-icons.js
@@ -108,7 +108,7 @@ export default {
         let iconItem = getIconItem(category.slug);
         if (iconItem) {
           let itemColor = iconItem[2]
-            ? iconItem[2] == "categoryColour"
+            ? iconItem[2].match(/categoryColo(u*)r/)
               ? `style="color: #${color}"`
               : `style="color: ${iconItem[2]}"`
             : "";
@@ -154,7 +154,11 @@ export default {
         html(attrs) {
           let iconItem = getIconItem(attrs.category.slug);
           if (iconItem) {
-            let itemColor = iconItem[2] ? `color: ${iconItem[2]}` : "";
+            let itemColor = iconItem[2]
+              ? iconItem[2].match(/categoryColo(u*)r/g)
+                ? `color: #${attrs.category.color}`
+                : `color: ${iconItem[2]}`
+              : "";
             let itemIcon = iconItem[1] != "" ? iconNode(iconItem[1]) : "";
             return h("span.category-icon", { style: itemColor }, itemIcon);
           }
diff --git a/settings.yml b/settings.yml
index 0d6f76c..16dacfe 100644
--- a/settings.yml
+++ b/settings.yml
@@ -2,7 +2,7 @@ category_icon_list:
   default: "help,question-circle,#CC0000,partial|"
   type: "list"
   list_type: "simple"
-  description: 'Enter comma-delimited configuration for categories, in the format "slug,icon,colour,match". Colour in format #123456 or "categoryColour" to use the default colour for the category (same as the Badge colour). If  match is "partial" then the slug need only partially match the category-slug, otherwise an exact match is required'
+  description: 'Enter comma-delimited configuration for categories, in the format "slug,icon,color,match". Colour in format #123456 or "categoryColor" to use the default color for the category (same as the Badge color). If  match is "partial" then the slug need only partially match the category-slug, otherwise an exact match is required'
 svg_icons:
   default: "question-circle"
   type: "list"

GitHub sha: 4c83914e

1 Like