diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index a268aed..207ee66 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -77,3 +77,12 @@ params:
- I am a Developer
- I work with Go
- I love to work with some fun projects
+
+outputs:
+ home:
+ - HTML
+ - JSON
+ - RSS
+ page:
+ - HTML
+ - RSS
\ No newline at end of file
diff --git a/layouts/_default/index.json b/layouts/_default/index.json
new file mode 100644
index 0000000..8215cd2
--- /dev/null
+++ b/layouts/_default/index.json
@@ -0,0 +1,5 @@
+{{- $.Scratch.Add "index" slice -}}
+{{- range .Site.RegularPages -}}
+ {{- $.Scratch.Add "index" (dict "title" .Title "tags" .Params.tags "content" .Plain "relPermalink" .RelPermalink "summary" .Summary) -}}
+{{- end -}}
+{{- $.Scratch.Get "index" | jsonify -}}
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index d2c0bf8..6260e9f 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -29,18 +29,27 @@
" + resultsMessage + "
"); + render(results); + } + else { + showCardssAndHideSearchResults(); + } + }; + + + var runSearch = function () { + if (searching) { + return; + } + var term = normalize($("#search-box").val()).trim(); + if (term === lastTerm) { + return; + } + lastTerm = term; + if (term.length < minChars) { + showCardssAndHideSearchResults(); + return; + } + searching = true; + var startSearch = new Date(); + $("#search-results").html('Processing search...
'); + var terms = term.split(" "); + var termsTree = []; + for (var i = 0; i < terms.length; i += 1) { + for (var j = i; j < terms.length; j += 1) { + var weight = Math.pow(2, j - i); + var str = ""; + for (var k = i; k <= j; k += 1) { + str += (terms[k] + " "); + } + var newTerm = str.trim(); + if (newTerm.length >= minChars && stopwords.indexOf(newTerm) < 0) { + termsTree.push({ + weight: weight, + term: " " + str.trim() + " " + }); + } + } + } + search(termsTree); + searching = false; + var endSearch = new Date(); + $("#search-results").append("Search took " + (endSearch - startSearch) + "ms.
"); + }; + var initSearch = function () { + $("#search-box").keyup(function () { + runSearch(); + }); + runSearch(); + }; + $("#search-box").hide(); + var searchHost = {}; + $.getJSON("/index.json", function (results) { + searchHost.index = []; + var dup = {}; + results.forEach(function (result) { + if (result.tags) { + var res = {}; + res.showTitle = result.title; + res.title = normalize(result.title); + res.subtitle = normalize(result.subtitle); + res.summary = result.summary; + res.content = normalize(result.content); + res.relPermalink = result.relPermalink; + var newTags_1 = []; + result.tags.forEach(function (tag) { + return newTags_1.push(normalize(tag)); + }); + res.tags = newTags_1; + searchHost.index.push(res); + dup[result.permalink] = true; + } + }); + $("#loading").hide(); + + $("#search-box").show() + .removeAttr("disabled") + .focus(); + initSearch(); + }); +}; +window.addEventListener("DOMContentLoaded", searchFn);