Skip to content

docs: add search (Algolia DocSearch) #310

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

Closed
5 of 6 tasks
justinmk opened this issue Dec 11, 2022 · 10 comments
Closed
5 of 6 tasks

docs: add search (Algolia DocSearch) #310

justinmk opened this issue Dec 11, 2022 · 10 comments
Labels
enhancement feature request

Comments

@justinmk
Copy link
Member

justinmk commented Dec 11, 2022

Alternatives

if Algolia doesn't work for some reason...

@shortcuts
Copy link
Contributor

great idea :) let me know if you need help implementing it!

@shortcuts
Copy link
Contributor

shortcuts commented Jun 13, 2023

Hey @justinmk, I was browsing the docs today and saw some potential improvements of the crawler config, here's an example of some changes I've made https://crvdgc.csb.app/

If you like it let me know, I could update the config for the nvim crawler :D

@justinmk
Copy link
Member Author

@shortcuts absolutely, can you share the config changes here? First thing I noticed is that the search results doesn't have that weird space.

neovim.io (has a weird space):

image

your site:

image

@justinmk justinmk added the enhancement feature request label Jun 14, 2023
@shortcuts
Copy link
Contributor

absolutely, can you share the config changes here?

Sure, I only changed the recordProps but there could still be improvements made especially if we want to highlight some parts of the docs with pageRank

          recordProps: {
            lvl0: {
              selectors: [
                "header h1",
                "article h1",
                "main h1",
                "h1",
                "head > title",
              ],
              defaultValue: "Documentation",
            },
            lvl1: ["article h2", "main h2", "h2"],
            lvl2: ["article h3", "main h3", "h3"],
            lvl3: ["article h4", "main h4", "h4"],
            lvl4: ["article h5", "main h5", "h5"],
            lvl5: ["article h6", "main h6", "h6"],
            content: [".help-tag", ".help-tag-right"],
          },

First thing I noticed is that the search results doesn't have that weird space.

I guess there might be some theming overlap with your CSS, looking at the code I can see that bootstrap apply some padding over the mark element, which might cause these small spaces

@shortcuts
Copy link
Contributor

hey @justinmk, I have a bit of time this weekend if you want I can provide a PR to fix the DocSearch style along with updating the config on the Algolia side

@justinmk
Copy link
Member Author

@shortcuts yes, style updates are very appreciated whenever you get a chance.

along with updating the config on the Algolia side

If you have other config hints to share please do, though I guess that can't be done as a PR.

@shortcuts
Copy link
Contributor

shortcuts commented Jun 27, 2023

@shortcuts yes, style updates are very appreciated whenever you get a chance.

sure, will take a look :)

If you have other config hints to share please do, though I guess that can't be done as a PR.

I don't have other hints for now but as I'm a DocSearch maintainer and I work on the Crawler at Algolia, I can update the config from there if you don't have time to do it

@justinmk
Copy link
Member Author

I'm a DocSearch maintainer and I work on the Crawler at Algolia, I can update the config from there if you don't have time to do it

Interesting... 😆 yes, that would be great! The "diff" of changes would be nice to see here, for reference.

@shortcuts
Copy link
Contributor

The "diff" of changes would be nice to see here, for reference.

Here's a screenshot of the diff from the Crawler UI directly, and the textual one in case you want to manually revert it. I applied the change but did not ran it yet in case you wanted to do it yourself or wait for the next schedule to kick in.

Screenshot 2023-06-27 at 22 16 59
- recordProps: {
-   lvl0: {
-     selectors: "",
-     defaultValue: "Documentation",
-   },
-   lvl1: ["header h1", "article h1", "main h1", "h1", "head > title"],
-   lvl2: ["article h2", "main h2", "h2"],
-   lvl3: ["article h3", "main h3", "h3"],
-   lvl4: ["article h4", "main h4", "h4"],
-   lvl5: ["article h5", "main h5", "h5"],
-   lvl6: ["article h6", "main h6", "h6"],
-   //content: ["div.old-help-para", "div.help-para"],
-   content: [".help-tag", ".help-tag-right"],
- },
+ recordProps: {
+   lvl0: {
+     selectors: [
+       "header h1",
+       "article h1",
+       "main h1",
+       "h1",
+       "head > title",
+     ],
+     defaultValue: "Documentation",
+   },
+   lvl1: ["article h2", "main h2", "h2"],
+   lvl2: ["article h3", "main h3", "h3"],
+   lvl3: ["article h4", "main h4", "h4"],
+   lvl4: ["article h5", "main h5", "h5"],
+   lvl5: ["article h6", "main h6", "h6"],
+   //content: ["div.old-help-para", "div.help-para"],
+   content: [".help-tag", ".help-tag-right"],
+ },

I'll take a look at the rendering issue :)

@justinmk
Copy link
Member Author

Nice, looks good! I see that I had lvl1 messed up.

justinmk pushed a commit that referenced this issue Jun 28, 2023
Problem:
The default bootstrap style adds padding to the `mark` element, which
adds unwanted space in the Algolia DocSearch results.

Solution:
Override the `mark` element, only if it's a child of the `DocSearch` class.

Discussed in #310
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request
Projects
None yet
Development

No branches or pull requests

2 participants