tags and searching

This commit is contained in:
Anthony Stirling
2023-07-23 23:05:02 +01:00
parent 940f8d999e
commit 295357f12b
5 changed files with 84 additions and 47 deletions

View File

@@ -43,9 +43,11 @@ document.querySelector('#navbarSearchInput').addEventListener('input', function(
var titleElement = item.querySelector('.icon-text');
var iconElement = item.querySelector('.icon');
var itemHref = item.getAttribute('href');
var tags = item.getAttribute('data-tags') || ""; // If no tags, default to empty string
if (titleElement && iconElement && itemHref !== '#') {
var title = titleElement.innerText;
if (title.toLowerCase().indexOf(searchText) !== -1 && !resultsBox.querySelector(`a[href="${item.getAttribute('href')}"]`)) {
if ((title.toLowerCase().indexOf(searchText) !== -1 || tags.toLowerCase().indexOf(searchText) !== -1) && !resultsBox.querySelector(`a[href="${item.getAttribute('href')}"]`)) {
var result = document.createElement('a');
result.href = itemHref;
result.classList.add('dropdown-item');
@@ -70,3 +72,4 @@ document.querySelector('#navbarSearchInput').addEventListener('input', function(
resultsBox.style.width = window.navItemMaxWidth + 'px';
});