To use on categories and subcategories I ammended the code as this:
<script>
Discourse.ExternalNavItem = Discourse.NavItem.extend({
href : function() {
return this.get('href');
}.property('href')
});
I18n.translations.en.js.filters.unanswered = { title: "Unanswered", help: "Topics that have not be answered" };
Discourse.NavItem.reopenClass({
buildList : function(category, args) {
var list = this._super(category, args);
if(!category) {
list.push(Discourse.ExternalNavItem.create({href: '/latest?max_posts=1', name: 'unanswered'}));
} else if (!category.parentCategory) {
list.push(Discourse.ExternalNavItem.create({href: '/c/' + category.slug + '?max_posts=1', name: 'unanswered'}));
} else {
list.push(Discourse.ExternalNavItem.create({href: '/c/' + category.parentCategory.slug + '/' + category.slug + '?max_posts=1', name: 'unanswered'}));
}
return list;
}
});
</script>