So I am using lunr.js in my Jekyll application to implement a search feature and the results return correctly. The aim is to then display the list of results in the browser.
Here I get the results, then pass them to a func which handles the DOM manipulation.
var results = idx.search(searchTerm); // Get lunr to perform a search
displaySearchResults(results, window.store);
The log of console.log(window.store);
is the following:
"python-2019-03-23-welcome-to-jekyll-html": Object { title: "test", category: "Python", url: "/python/2019/03/23/welcome-to-jekyll.html" }
The first key python-2019-03-23-welcome-to-jekyll-html
doesn't matter as that will change depending on the number of posts. How can I get the values of Object{}
?
Any advice would be appreciated. I'm fairly new to JS, so if this is badly worded, let me know.
You grab the first key of the window.store and then you can get the values you want
const { title, category, url } = window.store[Object.keys(window.store)[0]];