I never really liked the way this was generated, as it didn’t exactly match the other dropdowns. I’ve since rectified that here, and will now update GIT.
Revised navigation code
<li class='nav-item' title=''>
<a class='nav-link nav-btn navigation-link px-3 py-2' href='/categories'>
<span class='d-inline-flex justify-content-between align-items-center w-100'>
<span class='text-nowrap'>
<i class='fa-regular fa-list fa-solid menu-icon' data-content='' aria-hidden='true'> </i>
<span class='nav-text px-2 fw-semibold'>All Categories</span>
</span>
<span component='navigation/count' class='badge rounded-1 bg-primary hidden'></span>
</span>
</a>
<ul class='tree-branch' style='list-style: none;'></ul>
</li>
<li id='thecategories'><h6 class='dropdown-header text-xs'>Individual Categories</h6></li>
Revised category list code
$(document).ready(function() {
$.getJSON('/api/categories', function(data, status) {
$.each(data.categories, function(key, value) {
var iconClass = 'fa-regular'; // Default to 'fa-regular' if the icon type is not recognized
// Check if the icon is FontAwesome Unicode
if (this.icon.startsWith('&#x') || this.icon.startsWith('')) {
iconClass = 'fa-regular';
} else if (this.icon.startsWith('fab')) {
iconClass = 'fab';
}
var categorylist = $("<li class='nav-item' title=''> \
<a class='nav-link nav-btn navigation-link px-3 py-2' href='/category/" + this.slug + "'> \
<span class='d-inline-flex justify-content-between align-items-center w-100'> \
<span class='text-nowrap'> \
<i class='" + iconClass + " " + this.icon + " menu-icon' data-content='' aria-hidden='true'></i> \
<span class='nav-text px-2 fw-semibold'>" + this.name + "</span> \
</span> \
<span component='navigation/count' class='badge rounded-1 bg-primary hidden'></span> \
</span> \
</a> \
<ul class='tree-branch' style='list-style: none;'>" +
this.children.map(c => {
var childIconClass = 'fa-regular'; // Default to 'fa-regular' for child icons
// Check if the child icon is FontAwesome Unicode
if (c.icon.startsWith('&#x') || c.icon.startsWith('')) {
childIconClass = 'fa-regular';
} else if (c.icon.startsWith('fab')) {
childIconClass = 'fab';
}
return `<li class='nav-item tree-node' title=''><a class='nav-link nav-btn navigation-link px-3 py-2' href='/category/${c.slug}'><span class='d-inline-flex justify-content-between align-items-center w-100'><span class='text-nowrap'><i class='${childIconClass} ${c.icon} menu-icon' data-content='' aria-hidden='true'></i><span class='nav-text px-2 fw-semibold'>${c.name}</span></span><span component='navigation/count' class='badge rounded-1 bg-primary hidden'></span></span></a></li>`;
}).join(" ") +
"</ul> \
</li>");
if ($(window).width() < 767) {
$(".bottombar #thecategories").append(categorylist);
} else {
$(".sidebar-left #thecategories").append(categorylist);
}
});
});
});
Minor CSS changes (only the styles listed below)
ul.tree-branch {
border-left: 1px solid var(--bs-link-color);
margin-left: 22px;
}
li.tree-node:before {
border-bottom: 1px solid var(--bs-link-color);
position: relative;
top: 1.4em;
width: 35px;
content: "";
display: flex;
left: -33px;
}