Skip to content

Instantly share code, notes, and snippets.

@mnyrop
Created September 13, 2017 20:31
Show Gist options
  • Save mnyrop/a0a8834e29a3d3ed403242660719f87b to your computer and use it in GitHub Desktop.
Save mnyrop/a0a8834e29a3d3ed403242660719f87b to your computer and use it in GitHub Desktop.
sample jquery for dynamic display of lunr query results (for jekyll CI post)
$(document).ready(function() {
$('input#search').on('keyup', function () {
var resultdiv = $('#results');
// Get query
var query = $(this).val();
// Search for it
var result = idx.search(query);
// Show results
resultdiv.empty();
for (var item in result) {
var ref = result[item].ref;
var searchitem = '<div class="result"><a href="'+store[ref].link+'">'+store[ref].title+'</a></div>';
resultdiv.append(searchitem);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment