docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Choose search page version with URL argument

Open RoiArthurB opened this issue 2 years ago • 3 comments

Have you read the Contributing Guidelines on issues?

Description

It would be very useful to be able to pre-select version number for the search page with a URL argument.

Has this been requested on Canny?

Not that I found

Motivation

This feature would allow embedding the search page on other tools (website, IDE, else) by pointing directly to the wanted page.

In my use-case, developing an IDE with a custom programming language, it would allow me to have the documentation and an open search box with the wanted version already pre-selected for a smoother UX

API design

As it's simply a feature, it could be just enabled by default and not require any particular configuration.

Have you tried building it?

I simply gathered GET arguments from the URL and try to match it with one element from the list of available version. The URL looks something like this https://gama-platform.org/search?version=1.9.2

Self-service

  • [ ] I'd be willing to contribute this feature to Docusaurus myself.

RoiArthurB avatar Sep 29 '23 10:09 RoiArthurB

Could you please explain , more on this. Like is it creating a new Route path or is it setting the current version in the dropdown.

grbknr1996 avatar Oct 01 '23 16:10 grbknr1996

I was more thinking about setting the dropdown value with GET data. I'm not sure adding an extra Route path for this request would be overkill but it might be a good idea too :thinking:

RoiArthurB avatar Oct 02 '23 02:10 RoiArthurB

The issue is in this part

const SEARCH_PARAM_QUERY = 'q';
/**
 * Permits to read/write the current search query string
 */
export function useSearchQueryString(): [string, (newValue: string) => void] {
  return useQueryString(SEARCH_PARAM_QUERY);
}

So it needs to have 'q' parameter in order to make a query image

Now the question is whether I can twig this existing useSearchQueryString to something like this:

export function useSearchQueryString(key?:string): [string, (newValue: string) => void] { return useQueryString(key||SEARCH_PARAM_QUERY); }

image

If you could assign this issue to me @RoiArthurB Thanks in advance 👍 .This would be for Hacktoberfest 2023 .If there are any specific guidelines please let me know.

Did some changes :

image

grbknr1996 avatar Oct 02 '23 17:10 grbknr1996