docusaurus-search-local icon indicating copy to clipboard operation
docusaurus-search-local copied to clipboard

Add ignore pages option

Open JulesBlm opened this issue 3 years ago • 3 comments

Same as https://github.com/cmfcmf/docusaurus-search-local/pull/87. I made a new branch to avoid the potentially messy merge with upstream since the repo structure has changed. I will close the previous PR.

This adds an option to ignore pages so that they will not be included in the search index. For example, a long changelog page can pollute the search results and it's nice to be able to exclude such a page from the search index.

If the url to be ignored is added without the version, like: /docs/getting-started/intro it will be ignored for all versions. So for this example, these pages will be ignored: /docs/1.0.0/getting-started/intro /docs/2.0.0/getting-started/intro

The baseUrl is automatically prepended. So with baseUrl: 'foo', setting ignore to ['/docs/bar'] will exclude the /foo/docs/bar page from the search index.

It shows a warning if pages are defined in ignore but were not encountered.

JulesBlm avatar Mar 04 '22 12:03 JulesBlm

Thank you for the updates! I added some basic tests for this in a separate branch, see https://github.com/cmfcmf/docusaurus-search-local/tree/ignore-tests. However, these new tests are currently failing, because ignoring /docs/doc2 will not ignore doc2 for all documentation versions -- /docs/next/doc2 is still part of the search index.

cmfcmf avatar Mar 08 '22 19:03 cmfcmf

Thank you for the updates! I added some basic tests for this in a separate branch, see https://github.com/cmfcmf/docusaurus-search-local/tree/ignore-tests. However, these new tests are currently failing, because ignoring /docs/doc2 will not ignore doc2 for all documentation versions -- /docs/next/doc2 is still part of the search index.

Strange! I will check it out

JulesBlm avatar Mar 11 '22 09:03 JulesBlm

I got a bit swamped in other work but it turns out I was wrong about this

If the url to be ignored is added without the version, like: /docs/getting-started/intro it will be ignored for all versions.

I thought generating versioned pages happened afterwards, but it doesn't. Is there a way to get all the version strings in server/index.ts? I tried splitting strings but there were too many edge cases to get the versions strings reliably. Is it a good idea to import them from versions.json?

JulesBlm avatar Apr 05 '22 08:04 JulesBlm