cmfcmf / docusaurus-search-local

Offline / Local Search for Docusaurus v2. Try it live at:
https://cmfcmf.github.io/OpenWeatherMap-PHP-API/
MIT License
438 stars 67 forks source link

Add ignore pages option #87

Closed JulesBlm closed 2 years ago

JulesBlm commented 2 years ago

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.

cmfcmf commented 2 years ago

Thanks a lot for your PR! I am currently wondering about the big picture of this feature, specifically about the following (maybe @jjpank also has an opinion):

JulesBlm commented 2 years ago

Thank you for your reply and sorry for the long delay!

How does this interact with versioned documentation? I suppose you would need to ignore a page for all documentation versions separately?

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',

I don't think ignoring just a page of just one version is often (ever? who's to say) necessary. I'd suggest a wait-and-see approach, only add it if this feature is requested.

How does this interact with translated documentation? I you would need to separately ignore urls if translated docs also translate their slug in their front matter?

I still need to look into that.

Should we also add support for excluding entire directories?

It's a pretty good idea but personally I haven't found the need for it yet. Like ignoring a single page, I would hold off adding this.

How does this interact with baseUrl? I would prefer if the baseUrl is ignored when checking ignored paths (i.e. if the baseUrl is /foo, and a documentation page is at /foo/docs/bar, I would like that setting ignore: ['/docs/bar'] ignores the /foo/docs/bar page).

The baseUrl is already prepended so this works as one would expect.

I think we should show a warning if an entry from the ignore array is unused

Good idea, I will add this. I also think it might be good to show all pages that are actually ignored too.

JulesBlm commented 2 years ago

Made a new PR based on latest restructured main branch https://github.com/cmfcmf/docusaurus-search-local/pull/104