Comments (10)
Thanks for giving the plugin a whirl, sorry it didn't actually work!
I'll take a look at the problem tonight. Running it through your actual Jekyll site should make it straightforward to track down and fix.
from jekyll-lunr-js-search.
Thanks!
Also thanks for answering my query on SO about memory, good to know. I'm
wondering if I'll need to replace the search form that appears in my navbar
to keep search on a dedicated separate page. I noticed your Readme says
t also features on-demand loading of the search plugin .js when focusing
into the search field on the homepage http://10consulting.com/. Look at
the browser network requests clicking into the search input.
so perhaps it wouldn't be necessary to do that, since if I understand
correctly that the loading into memory doesn't happen until the user clicks
on the search field?
On Thu, Mar 7, 2013 at 2:26 AM, Ben Smith [email protected] wrote:
Thanks for giving the plugin a whirl, sorry it didn't actually work!
I'll take a look at the problem tonight. Running it through your actual
Jekyll site should make it straightforward to track down and fix.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-14547853
.
Carl Boettiger
UC Santa Cruz
http://www.carlboettiger.info/
from jekyll-lunr-js-search.
The on-demand loading isn't included in the plugin at the moment, but here's a gist of the JavaScript that I'm using to achieve this on the homepage of my website.
https://gist.github.com/slashdotdash/a9441baea14228ab84be
Here's the actual focus wireup and on-demand js loading part. It only does this once, regardless of how many times the input field gets focus.
// load the search .js file when the search query input gains focused (once)
var loadOnDemand = function(loaded) {
focused('search-query', once(function() {
demand('/js/search.min.js', loaded);
}));
};
Using this approach both the .js file and index JSON data are not actually requested from the server (or loaded into memory) until the user clicks/focuses on the search input field.
from jekyll-lunr-js-search.
Minified version can be included in standard <script>..</script>
tags in the html body so there are no external requests.
https://gist.github.com/slashdotdash/a9441baea14228ab84be#file-on-demand-search-min-js
from jekyll-lunr-js-search.
Above commit should fix your issue Carl. I've run the plugin on your site, albeit with all others removed, and it generated the search.json
index file.
Let me know if you encounter any problems.
from jekyll-lunr-js-search.
Thanks! That definitely fixed the ruby end, I can verify that search.json is being created correctly. The site now builds successfully ..., but I don't seem to be getting the javascript to run on my search.html
page. Current attempt here (site-search branch): https://github.com/cboettig/labnotebook/tree/b56794d74f4bf0fee91e355d10096ac2ffd50856
I haven't added the "load on select" script yet,but still probably me doing something stupid with the javascript. Thanks for the help!
from jekyll-lunr-js-search.
Had a play around and eventually got it working, couple of things were causing it to be unhappy.
- Exclude 404 page from search index (ensure
_config.yml
containslunr_excludes: [atom.xml, 404.html]
) - You already reference jQuery in the footer of your template. So the search JavaScript snippet and import script reference (
<script src="/assets/js/search.min.js" type="text/javascript" charset="utf-8"></script>
) need to be after jQuery is included. - Also related, use the following minified search.min.js which has jQuery removed https://gist.github.com/slashdotdash/f6be39fcd1ae2615a2b5
- The search results Mustache template needs to be wrapped in
{% raw %}
and{% endraw %}
tags so that the content is not stripped out by Jekyll
from jekyll-lunr-js-search.
Also the Mustache search results template needs to be as follows (some of the Jekyll tags were stripped on the blog post).
{% raw %}
<script id="search-results-template" type="text/mustache"> {{#entries}}{{#date}}{{displaydate}}{{/date}} {{title}}
{{/entries}} </script>{% endraw %}
from jekyll-lunr-js-search.
thanks. I've followed these changes but still no dice. Does search on the
search.html or 404.html pages work for you if you locally compile my site?
You've already gone above the call of duty I think in replying to my
particular case here, so no worries if you don't have time to look at this
again. not sure what I've missed.
Snapshot of my current build here:
https://github.com/cboettig/labnotebook/tree/b4c5141a6886218e7741173cb0674f54961adb27
The search page looks like a functional match to the one at
http://10consulting.com/search/ so I'm puzzled. I did try moving my
javascript to the header or turning off all other javascript too, but no
luck there either.
On Sun, Mar 10, 2013 at 3:38 AM, Ben Smith [email protected] wrote:
Also the Mustache search results template needs to be as follows (some of
the Jekyll tags were stripped on the blog post).{% raw %}
{{#entries}}{{#date}}{{displaydate}}{{/date}} {{title}}
{{/entries}}{% endraw %}
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-14679333
.
Carl Boettiger
UC Santa Cruz
http://www.carlboettiger.info/
from jekyll-lunr-js-search.
I'll send send you a pull request with the changes I made to get search working.
from jekyll-lunr-js-search.
Related Issues (20)
- Why it's always use lunr.js v0.4.5? HOT 3
- How to edit indexer.rb? HOT 1
- index.json url not referencing correct url HOT 2
- Support for other languages HOT 1
- Doesn't search the title HOT 1
- Installation instructions should be improved and clarified HOT 4
- Now the json 2.0.2 is out.... HOT 9
- Issue with Ruby 2.4?
- Conflict with newer json HOT 2
- Conflict between Gems?
- How do you compare this to Elasticlunr.js? HOT 1
- make index file sparse (no null props) HOT 4
- Seems Lunr.js doesn't support other language HOT 2
- Integrating jekyll-lunr-js-search into minimal-mistakes-theme HOT 1
- /usr/local/lib/ruby/gems/2.4.0/gems/therubyracer-0.12.3/lib/v8/function.rb:13: [BUG] Segmentation fault at 0x22be30 HOT 4
- [RFE] Consider switching from therubyracer to execJs HOT 1
- Index doesn't contains everything
- find: `out': No such file or directory HOT 2
- Get surrounding text?
- New Repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jekyll-lunr-js-search.