Skip to content
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

Add a way for Docsy users to add custom search functionality #2194

Open
SayakMukhopadhyay opened this issue Feb 12, 2025 · 4 comments
Open
Labels
enhancement New feature or request needs-triage

Comments

@SayakMukhopadhyay
Copy link
Contributor

SayakMukhopadhyay commented Feb 12, 2025

In the Kubernetes docs website project (https://kubernetes.io / https://github.com/kubernetes/website/), we use a custom search implementation, mostly because how it handles Google search engine having geo-blocks. Unlike Docsy, where only a single search engine can be enabled at a time, we override Docsy's search handling with our own script which can switch search engines based on the geo-restrictions.

Now, in our case, the capability of Docsy to have multiple search engines is not important as I can understand that it would be infeasible for Docsy to allow arbitrary combinations of search engines. Rather, I think it would be great to have a hook in Docsy which can be used by Docsy users to add their own search functionality without needing to override multiple other files.

Right now, k8s website overrides multiple files to add our own script.

My proposal is to add a new config param customSearch, like we have offlineSearch which will disable all Docsy provided search and allow us to add a assets/js/custom-search.js script. I think the change can be made in
https://github.com/kubernetes/website/blob/99e78ac65cd08a900ed5c42e15e38cf6c39f556e/layouts/partials/scripts.html#L36-L37 by reassigning jsSearch to the contents of the custom-search.js file, exactly the way, offline search is done.

This change would also make things much cleaner for those having custom search tools like using other online search engines or local ones like Pagefind.

I would be happy to create a PR for this.

@sftim
Copy link

sftim commented Feb 12, 2025

Former tech lead for Kubernetes docs here. I'm also willing to help on this.

@fekete-robert
Copy link
Collaborator

https://github.com/google/docsy/pull/1512/files might be somewhat related

@SayakMukhopadhyay
Copy link
Contributor Author

https://github.com/google/docsy/pull/1512/files might be somewhat related

Yep, that PR would also help us. Although, I would have prefered a parameter guard for the custom search and not it being automatically implemented when all search options are disabled as someone might not want search at all.

@SayakMukhopadhyay
Copy link
Contributor Author

SayakMukhopadhyay commented Mar 5, 2025

Disregard my last comment regarding the guard. I now realise that if all search options are disabled and the search-input-custom partial is not present, it will cause search to be disabled completely and hence no extra guards are needed.

Still, I wonder if it would be better to have an explicit guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-triage
Projects
None yet
Development

No branches or pull requests

3 participants