Adding client-side search bar#149
Conversation
humphd
left a comment
There was a problem hiding this comment.
I tried this locally, and it seems to work. It looks like it builds after the service worker, though, which means it might not cache the index. I'm not sure.
I also don't totally understand what it's indexing, or if I did it correctly, since very few results are returned. How do you run it?
Remove package-lock.json since we use yarn
We need some left margin to give space between the theme picker and search, they are too close:
| @@ -0,0 +1,276 @@ | |||
| import Hogan from 'hogan.js'; | |||
There was a problem hiding this comment.
Where is this coming from? I don't see it in this PR
There was a problem hiding this comment.
Hogan is a dependency comes with docusaurus-lunr-search, I don't know it is not installed automatically for some reason.
* Adding margin and remove package-lock.json * Install dependency Hogan.js
|
Hi ! What's the status of this PR? |
| ? fetch(`${baseUrl}${pluginData.fileNames.searchDoc}`).then((content) => content.json()) | ||
| : Promise.resolve([]); | ||
|
|
||
| const getLunrIndex = () => |
There was a problem hiding this comment.
Since this function does a pretty similar job as getSearchDoc(), it would be a good idea to create a function that takes the subURL as its parameter and fetches data the same way as these 2 functions do, and just call this function inside getSearchDoc() and getLunrIndex with their subURL respectively.
|
If someone wants to take this over, that might be good @mnosov622, @liutng. We can close this one and replace with a new, updated PR if one (or both) of you want to work on that. |
|
@liutng let's work on this one together? |

Working on issue #125
Thanks to docusaurus-lunr-search, I have added a search bar and added some plugin configuration.
Note: The search bar works based on
build, and thenserve. I have tested it locally, but theindexBaseUrldid not work on local machine.