ثيم سام البسيط

Do not know where to add, I want to share. In this example, you can see how to change the individual elements in the design. I do not know how true this approach is.

Add:

PLAGIN/assets/javascripts/discourse/helpers/catid-img.js.es6

import { registerUnbound } from 'discourse-common/lib/helpers';

var get = Em.get,
    escapeExpression = Handlebars.Utils.escapeExpression;

export function categoryBadgeHTML(category, opts) {
  opts = opts || {};

  let categoryID = escapeExpression(get(category, 'id'));
  let img = Discourse.Category.findById(categoryID).uploaded_logo.url;
  let categoryName = escapeExpression(get(category, 'name'));
  let url = opts.url ? opts.url : Discourse.getURL("/c/") + Discourse.Category.slugFor(category); 
 
  return `<a class="catid-url" title="${categoryName}" href="${url}"><img src="${img}" alt="${categoryName}" class="catid-logo"></a>`;
}

export function categoryLinkHTML(category, options) {
  var categoryOptions = {};
  return new Handlebars.SafeString(categoryBadgeHTML(category, categoryOptions));
}

registerUnbound('catid-img', categoryLinkHTML);

Add:

Toxu-cat

{{catid-img topic.category}}

The output of category icons:

P.S. perhaps this can be done in another way, more easier, but it is easier for me to add 1 file to the plugin.

3 إعجابات