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

Is it possible to customize/extend search functionality to more than just names? #14724

Closed
chadlavi-casebook opened this issue Apr 26, 2021 · 7 comments

Comments

@chadlavi-casebook
Copy link

chadlavi-casebook commented Apr 26, 2021

I'd like to be able to include more than just the page name in search. For example, if I have an MDX page about input usage rules, and one of the sections of that page is about validations, then if a user searches "validation" on my storybook, I want this page to come up as a result.

Is there anything like, the ability to add keywords to a <Meta> or something? I can't find anything in the docs about this.

@shilman
Copy link
Member

shilman commented Apr 27, 2021

We don't currently have any plans for this. In an older version of search it included various extra fields (like parameters.notes) but this resulted in a very confusing UX. I think the closest thing to a solution would be #7711, but this isn't implemented yet cc @ghengeveld

@chadlavi-casebook
Copy link
Author

@shilman thanks. To get these in the search index, is the recommended pattern breaking up larger MDX files into smaller files that are part of the same sub-section instead? Something like a single MDX file Inputs / Usage guide moving to Inputs / Usage Guide / ... with individual MDX files for each section in the former file?

I wish it were possible to do this while still keeping those individual sections within a single scrollable page.

@shilman
Copy link
Member

shilman commented Apr 28, 2021

The current search really isn't designed for this use case, so I hesitate to even recommend a workaround. That said, if I wanted to hack the system, I would do something like this in your MDX file:

# Here is my page

<Story name="Page title"></Story>

I'm going to type something here about my page

<Story name="Searchable"></Story>

More text here

<Story name="Another custom term"></Story>

...

I tried this and it kind of works. Each story generates a heading under Page title. The canvas for each story is blank. The name of each story is searchable. Clicking on the story scrolls to that part of the page.

@as-zlynn-philipps
Copy link

as-zlynn-philipps commented Jan 21, 2022

@shilman Unfortunately that doesn't work in 6.4.12, I get render.js:49 Uncaught Error: Unable to render story docs-theme-reference-colors--customizing-colors as the component annotation is missing from the default export.

I'd love it if there was an option to turn on/off the ability to search by heading. Then clicking a result takes you directly to the anchor link. That workaround would kind of work like you said if it didn't throw an error.

There are things that don't make sense to have a story, like configuration examples (theming is what I'm working on currently.)

@as-zlynn-philipps
Copy link

as-zlynn-philipps commented Jan 21, 2022

Actually, that does work with an empty fragment:

<Story name="Searchable title"><></></Story>

Neat!

@shilman
Copy link
Member

shilman commented Jun 8, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:

@shilman shilman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
@jrencz
Copy link
Contributor

jrencz commented Jun 8, 2023

@shilman

I understand the need to reduce the backlog but in here it's not a problem with something working not as expected (which fits into the "reproduce" concept) but rather a request to add something that's missing. Are there recommendations on how to reproduce "lack of something"?

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

No branches or pull requests

4 participants