Add tags, path to search results

This commit is contained in:
Akbar Rahman 2021-08-19 15:31:28 +01:00
parent 3f50d9da28
commit c51b8a302a
2 changed files with 24 additions and 1 deletions

View File

@ -11,13 +11,28 @@ function callback() {
results.innerHTML = '' results.innerHTML = ''
fuse.search(searchBar.value).forEach(r => { fuse.search(searchBar.value).forEach(r => {
wrapper = document.createElement('div') wrapper = document.createElement('div')
wrapper.className = "article"
extra_info = document.createElement('p')
extra_info.className = "smallText"
extra_info.innerHTML = "tags: "
if (r.item.tags == null) {
extra_info.innerHTML += "none"
} else {
extra_info.innerHTML += "[" + r.item.tags.join(', ') + ']'
}
extra_info.innerHTML += ' path: ' + r.item.path
content = document.createElement('a') content = document.createElement('a')
content.innerHTML = r.item.title content.innerHTML = r.item.title
content.href = r.item.path content.href = r.item.path
wrapper.appendChild(content) wrapper.appendChild(content)
wrapper.className = "article" wrapper.appendChild(extra_info)
results.appendChild(wrapper) results.appendChild(wrapper)
}) })
} }
searchBar.addEventListener('keyup', callback) searchBar.addEventListener('keyup', callback)
callback()

View File

@ -83,3 +83,11 @@ blockquote * {
#results { #results {
overflow-x: scroll; overflow-x: scroll;
} }
.smallText {
font-size: 0.7em;
}
.article .smallText {
margin: 0
}