Sha256: c02a5e1eec2103480f341e0dec28dbc289a7921344e9ef933ee679ed4f4cf4d1
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
<form id="searchform"> <p><input type="text" id="search-input" class="form-control" name="q" value="" autofocus /></p> </form> <ul id="searchresults" class="post-list"></ul> <script src="/assets/js/search.js" type="text/javascript"></script> <script> var sjs = SimpleJekyllSearch({ searchInput: document.getElementById('searchform'), resultsContainer: document.getElementById('searchresults'), json: '/assets/js/posts.json', templateMiddleware: function(prop, value, template) { if (prop === "title" || prop === "excerpt") { value = value.replace(/&/g, "&"); } return value.replace( new RegExp(document.getElementById('search-input').value, "gi"), '<span class="highlight">$&</span>' ) }, sortMiddleware: function(a, b) { aPrio = matchPriority(a.matchedField) bPrio = matchPriority(b.matchedField) return bPrio - aPrio }, searchResultTemplate: "<li class='card'>" + "<div class='content'>" + "<a class='post-link' href='{url}'>{title}</a>" + "<span class='post-meta'>{date} • {tags}</span>" + "<p>{excerpt}</p>" + "</div>" + "</li>" }) function matchPriority (fieldMatched) { switch (fieldMatched) { case 'tags': return 5; case 'title': return 4; case 'excerpt': return 3; default: return 0; } } window.addEventListener('load', function() { var searchParam = new URLSearchParams(window.location.search).get("q") if (searchParam != null) { document.getElementById('search-input').value = searchParam sjs.search(searchParam) } document.getElementById('search-input').placeholder = "Type your search here..." }, false); </script>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minimaJake-1.0.4 | _includes/custom/search.html |