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

display search result with a tree #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Florent-Bouisset
Copy link
Collaborator

The idea of this proposal is to display results with a tree when searching on the doc.

image

There is an issue if the search result include a subsection but not the parent section, in this case the subsection is orphan, I'm not sure how to handle that.

@Florent-Bouisset
Copy link
Collaborator Author

image It's a bit tricky but I think I solved the issue I mentioned

@Florent-Bouisset Florent-Bouisset force-pushed the feat/search-result-indented branch 2 times, most recently from 7559523 to dbd7f32 Compare January 8, 2025 14:28
@Florent-Bouisset Florent-Bouisset force-pushed the feat/search-result-indented branch from dbd7f32 to 7a6df87 Compare January 8, 2025 14:30
return r.item.h2 === undefined;
});
if (topSection === undefined) {
const fakeH1 = structuredClone(value[0]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no idea what we're trying to do there with those fakeH1 = ... (fakeH1 is an object?), it may need comments

}

for (const value of Object.values(h1Sections)) {
const topSection = value.find((r) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments of that function says that a top section is h1 but here apparently it's h2, I'm lost

@@ -439,6 +439,7 @@ function initializeSearchEngine() {
anchorH3: elt.anchorH3,
});
pageIndex.push({
file: res[i].file,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already present in searchIndexLinks no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but If I don't add it there, there is no way to distinguish if 2 items come from the same page

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me the id property is supposed to make the link between the two or I miss something?

}
// Create the h1 key
if (!grouping[item.file][item.h1]) {
grouping[item.file][item.h1] = {};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So from here we consider that h1 cannot be undefined?

@@ -478,6 +479,8 @@ function initializeSearchEngine() {
return searchState.promise;
}

const __DEFAULT_SYMBOL__ = Symbol("__DEFAULT__");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice symbol usage, I like the idea.
We could add a comment

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

Successfully merging this pull request may close these issues.

2 participants