Add tags, path to search results
This commit is contained in:
parent
3f50d9da28
commit
c51b8a302a
17
search.js
17
search.js
@ -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()
|
||||||
|
@ -83,3 +83,11 @@ blockquote * {
|
|||||||
#results {
|
#results {
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.smallText {
|
||||||
|
font-size: 0.7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article .smallText {
|
||||||
|
margin: 0
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user