From c51b8a302abac6a78d60dc4eb6e3a27016a6b547 Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Thu, 19 Aug 2021 15:31:28 +0100 Subject: [PATCH] Add tags, path to search results --- search.js | 17 ++++++++++++++++- styles.css | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/search.js b/search.js index 82a059e..abb657d 100644 --- a/search.js +++ b/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() diff --git a/styles.css b/styles.css index ad57182..c76a7e5 100644 --- a/styles.css +++ b/styles.css @@ -83,3 +83,11 @@ blockquote * { #results { overflow-x: scroll; } + +.smallText { + font-size: 0.7em; +} + +.article .smallText { + margin: 0 +}