mirror of
https://github.com/alvierahman90/gronk.git
synced 2024-11-22 07:19:53 +00:00
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 = ''
|
||||
fuse.search(searchBar.value).forEach(r => {
|
||||
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.innerHTML = r.item.title
|
||||
content.href = r.item.path
|
||||
|
||||
wrapper.appendChild(content)
|
||||
wrapper.className = "article"
|
||||
wrapper.appendChild(extra_info)
|
||||
|
||||
results.appendChild(wrapper)
|
||||
})
|
||||
}
|
||||
|
||||
searchBar.addEventListener('keyup', callback)
|
||||
callback()
|
||||
|
@ -83,3 +83,11 @@ blockquote * {
|
||||
#results {
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
.smallText {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
.article .smallText {
|
||||
margin: 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user