{% raw %} <scriptid="search-results-template"type="text/mustache"> {{#entries}} <article> <h3> {{#date}}<small><time datetime="{{pubdate}}" pubdate>{{displaydate}}</time></small>{{/date}} <a href="{{url}}">{{title}}</a> </h3> </article> {{/entries}} </script> {% endraw %} <scripttype="text/javascript"> $(function() { $('#search-query').lunrSearch({ indexUrl: '/search.json', // URL of the `search.json` index data for your site results: '#search-results', // jQuery selector for the search results container entries: '.entries', // jQuery selector for the element to contain the results list, must be a child of the results element above. template: '#search-results-template' // jQuery selector for the Mustache.js template }); }); </script>
Mustache.compile = function (template) { // This operation parses the template and caches // the resulting token tree. All future calls to // mustache.render can now skip the parsing step. Mustache.parse(template); returnfunction (view, partials) { returnMustache.render(template, view, partials); }; };
也可以修改jekyll_lunr_js_search.rb文件,找到File.open(File.join(site.dest, filename), "w") do |file|,修改代码为
1 2 3 4 5 6
File.open(File.join(site.dest,"../", filename), "w") do |file| file.write(json) end # Keep the search.json file from being cleaned by Jekyll site.static_files << Jekyll::SearchIndexFile.new(site, site.dest, "../", filename) end