-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
docs: Add stub articles for search guides #10772
Conversation
@m-allanson i'm working on documentating how to search with reactivesearch. I can expand the document i'm producing for both of elasticunr and js-search also. Algolia for me it's not something i really not that confortable, so i'll refrain from expanding that stub and probably fumble fingering it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Left a comment on a code style thing, feel free to take or leave it!
@@ -15,9 +15,26 @@ import docsHierarchy from "../data/sidebars/doc-links.yaml" | |||
// Find the guides in the sidebar YAML. | |||
const guides = docsHierarchy.find(group => group.title === `Guides`).items | |||
|
|||
// Search through the guides and their children to find the first item that | |||
// matches the given slug | |||
const findBySlug = (guides, slug) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks better, but I wonder if we could make it less side-effecty with a .find
and perhaps a flatten? Here's a start:
const flatten = arr => arr.reduce((merged, item) => merged.concat(Array.isArray(item.items) ? flatten(item.items) : item), [])
const findBySlug = (guides, slug) => {
return flatten(guides)
.find(item => item.link === slug)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presuming we have a structure like (for guides):
const guides = [
{
link: '/test'
},
{
items: [
{
link: '/test2'
}
]
}
]
this seems to work just fine!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a little play around with this but I don't think flatten is right here, as we want to grab the child items from the item with the matching slug. I rejigged some other bits while playing around with this though, thank you 👍
Co-Authored-By: m-allanson <michael.allanson@gmail.com>
Co-Authored-By: m-allanson <michael.allanson@gmail.com>
Co-Authored-By: m-allanson <michael.allanson@gmail.com>
ok, so with this merge now my pull request #11030 is basically throwing merge conflicts with what is now the master. If you don't mind, a little feedback would be appreciated on this matter |
Sorry I missed your comment earlier, I've fixed up the merge conflicts on your branch. |
Description
Update the existing search guide to act as an overview for more specific guides.
I've also updated the [[guidelist]] handler to remove the hardcoded paths (cc @jlengstorf)
Related Issues
Refs #10113