diff --git a/content/search.html.erb b/content/search.html.erb index c0734dd..c38f91a 100644 --- a/content/search.html.erb +++ b/content/search.html.erb @@ -87,7 +87,8 @@ function ready() { } const documents = <%= CreateFullTextIndex.new(@items.find_all("**/verenigingen/*") + @items.find_all("**/konventen/*")).call.to_json %>; - partials = <%= to_partials_search(all_groups()) %>; + const partials = <%= to_partials_search(all_groups()) %>; + const index = lunr(function () { this.field('id', {boost: 15}); this.field('title', {boost: 10}); @@ -101,7 +102,7 @@ function ready() { doSearch = (query) => { clearDiv(wrapper); - render_results(wrapper, index.search(query).sortByKey(i => partials[i.ref].titel).stableSort((a, b) => b.score - a.score).map(i => partials[i.ref])); + render_results(wrapper, index.search(query).sortByKey(i => partials[i.ref].titel).stableSort((a, b) => b.score - a.score).map(i => partials[i.ref].html)); window.history.pushState("search state", "", window.location.pathname + "?q="+query); }; diff --git a/content/stylesheets/main.css b/content/stylesheets/main.css index 8725cc4..a38df4d 100644 --- a/content/stylesheets/main.css +++ b/content/stylesheets/main.css @@ -435,7 +435,7 @@ fieldset p label input { gap: 20px; padding: 0.5rem; - max-width: 700px; + max-width: 600px; flex-grow: 1; min-width: 20%; } @@ -446,7 +446,6 @@ fieldset p label input { gap: 20px; flex-wrap: wrap; justify-content: space-evenly; - } .link:hover { diff --git a/layouts/partials/pretty_link.erb b/layouts/partials/pretty_link.erb index a5a9866..cec51c2 100644 --- a/layouts/partials/pretty_link.erb +++ b/layouts/partials/pretty_link.erb @@ -1,4 +1,4 @@ - + @@ -10,4 +10,4 @@ <%= text_segment(item.compiled_content) %> - + diff --git a/lib/helpers/search.rb b/lib/helpers/search.rb index 25d6b55..93f7a2d 100644 --- a/lib/helpers/search.rb +++ b/lib/helpers/search.rb @@ -30,7 +30,10 @@ module SearchHelper my_hash = {} items.each do |item| - my_hash[(item.path)] = (render '/partials/pretty_link.*', :item => item).gsub("\n", '') + my_hash[(item.path)] = { + html: (render '/partials/pretty_link.*', :item => item).gsub("\n", ''), + titel: item[:titel] || item[:naam] + } end my_hash.to_json end