-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search #18
Conversation
// Initialize lunrjs using our generated index file | ||
function initLunr() { | ||
// First retrieve the index file | ||
$.getJSON("/json/search.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems does not work if baseurl = "https://foo/bar"
GET https://foo/json/search.json instead of https://foo/bar/json/search.json
<input id="search-by" type="text" placeholder="Search Documentation" data-search-input="/lunr.json/query"> | ||
<span data-search-clear=""><i class="fa fa-close"></i></span> | ||
</div> | ||
{{ partial "search.html" . }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be more flexible if {{ partial "search.html" . }} is not in header class, like :
<nav id="sidebar">
<div id="header-wrapper">
<div id="header">
{{ partial "logo.html" . }}
</div>
{{ if .Site.Params.search }}
{{ partial "search.html" . }}
{{ end }}
</div>
|
||
And set `search = true` in your config.toml | ||
|
||
To generate your lunr index, you can see this project https://github.com/gwleclerc/lunr-hugo which parse your markdown files and extract toml and yaml headers to create index with corresponding format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a full example step by step to use this lib here ?
And for :
--> Title is not included in search.json after running lunr-hugo. meta.data.title is empty here https://github.com/gwleclerc/lunr-hugo/blob/master/lib/index.js#L123 |
very strange because it does work with ---
title: Get started
icon: '<i class="fa fa-road"></i>'
chapter: true
aliases:
- /start
next: "/start/introduction"
weight: 0
--- |
I launch lunr-hugo using this command: |
… + add a step to explain how to use lunr-hugo + update perfect-scrollbar
Thanks @gwleclerc for your new commit. Could you :
|
Although I have installed npm and lunr-hugo I get the |
@ilyasustun you don't need lunr anymore to use search feature in v2 version. But your problem is probably because npm binary folder is not in your PATH environment variables (or you opened a cmd before installing npm) |
Thanks for the prompt answer. Is v2 the version of hugo or learn-theme? |
Hey I got it fixed. I used Another important question: If I have both |
v2 is for learn theme. Both should work as search (at least in v2) is working from hugo There is still an open issue about R Markdown though |
I have managed to create the search.json file by using |
Add search feature and close issue #12