Giter Site home page Giter Site logo

lukewhitehouse / gatsby-starter-blog-with-lunr Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 5.0 1.19 MB

Building upon Gatsby's blog starter with a Lunr.js powered Site Search. https://gatsby-starter-blog-with-lunr.netlify.com/

Home Page: https://assortment.io/posts/gatsby-site-search-lunr-js

License: MIT License

JavaScript 98.71% CSS 1.29%

gatsby-starter-blog-with-lunr's People

Contributors

lukewhitehouse avatar markoskon avatar mikefrancis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gatsby-starter-blog-with-lunr's Issues

Some feedback

I know you didn't ask for it but I'll write it anyway because I like your posts.

  • If you press : in the search you get this error:
O.QueryParseError {name: "QueryParseError", message: "unrecognised field '', possible fields: 'title', 'description', 'content', 'url', 'date'"....
<p>
  <Highlighter
     searchWords={[query]}
     autoEscape={true}
     textToHighlight={description}
    />
</p>     
  • Clear the results when the input is cleared. Maybe something like this in the useEffect of search.js:
if (!searchQuery) setResults([])

useEffect has a missing dependancy

Hi,

Great search utility - thank you for sharing!

I have implemented your code but am getting the following message in the terminal:

warn ESLintError:
C:\home\lunr-search\src\pages\search.js
25:6 warning React Hook useEffect has a missing dependency: 'searchQuery'. Either include it or remove the dependency array react-hooks/exhaustive-deps

✖ 1 problem (0 errors, 1 warning)
0 errors and 1 warning potentially fixable with the --fix option.

I'm completely new to React and Gatsby, so this has stumpped me somewhat! Any help gratefully received.

Many thanks

Search on onkeyup?

Am reading your tutorial https://assortment.io/posts/gatsby-site-search-lunr-js where you ask for feedback. Hope here is OK. The tutorial is excellent. I have made a version of the blog with more text and frontmatter to check out functionality.

I noticed that mostly you have to type a full word in the search box before results are triggered. Just a few exceptions showed results before, eg entering "sweep" showed a record with "sweeping", and "privat" showed record with "private". But you must enter the entire word to get a record with "peninsula". Is there any way to trigger search after each onkeyup instead?

Subject to the above, the Submit button seems unnecessary as results appear when typing in the search term.

One last finding on search: once the search is triggered and results appear, if you carry on typing these results do not change. This is not desirable. For example one record has "look no further", another has "looking". Both appear after entering "look" but stay there after extending the search to "look further". Is there an easy solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.