Skip to content

Adding client-side search bar#149

Open
tcvan0707 wants to merge 1 commit into
Seneca-ICTOER:mainfrom
tcvan0707:issue-125
Open

Adding client-side search bar#149
tcvan0707 wants to merge 1 commit into
Seneca-ICTOER:mainfrom
tcvan0707:issue-125

Conversation

@tcvan0707

Copy link
Copy Markdown

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 then serve. I have tested it locally, but the indexBaseUrl did not work on local machine.

@humphd humphd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Screen Shot 2021-12-09 at 6 18 12 PM

@@ -0,0 +1,276 @@
import Hogan from 'hogan.js';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this coming from? I don't see it in this PR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@mnosov622

Copy link
Copy Markdown

Hi !

What's the status of this PR?

? fetch(`${baseUrl}${pluginData.fileNames.searchDoc}`).then((content) => content.json())
: Promise.resolve([]);

const getLunrIndex = () =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@humphd

humphd commented Nov 15, 2022

Copy link
Copy Markdown
Contributor

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.

@mnosov622

Copy link
Copy Markdown

@liutng let's work on this one together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants