How to add a topic in top nav in a specific category?

This seems no-longer works after deprecation of Discourse.NavItem , and someone mentioned in this post that Custom top navigation links can do the trick:

However, this component does not dynamic link where you want to check the link url based on current location.
For my use-case, I want to set different link for mainpage and sub-categories, e.g. to show an unfinished/finished tag filter nav item based on current categories, I used to able to use below code but now is not working:

<script>
Discourse.ExternalNavItem = Discourse.NavItem.extend({
    href : function() {
      return this.get('href');
    }.property('href')
  });

  I18n.translations.en.js.filters.unfinished = { title: "tbc", help: "placeholder" };
  I18n.translations.en.js.filters.finished = { title: "finished", help: "placeholder" };

  Discourse.NavItem.reopenClass({
    buildList : function(category, args) {
      var list = this._super(category, args);
      var url = category ? category.url : "";
      // Main menu and 2 specific categories will have those 2 nav items with different url
      if(!category || (category && url && (url.includes("mix") || url.includes("other")))) {
        var tbc_url = category ? "/tags" + url + "/tbc" : "/tags/tbc";
        var finish_url = category ? "/tags" + url + "/finished" : "/tags/finished";
        
        list.push(Discourse.ExternalNavItem.create({href: tbc_url, name: 'tbc'}));
        list.push(Discourse.ExternalNavItem.create({href: finish_url, name: 'finish'}));
      }
      return list;
    }
  });
</script>

Can someone help me on how can I update this code based on current navigation-item component? Or a more general question, how can I find the current usage of the replacement of Discourse.NavItem?

Thanks!

5 Likes