Skip to content

feat: add pagefind search #4247

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

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

Conversation

miketheman
Copy link
Member

@miketheman miketheman commented Jan 31, 2025

Instead of using sphinx's built-in search which has some challenges in its implementation, as well as the integration with the customized builder and theme, use a different approach.

Pagefind will generate fragments that can be loaded client-side efficiently.

Refs: https://pagefind.app/
Refs: https://pypi.org/project/pagefind/
Resolves #4083


📚 Documentation preview 📚: https://pep-previews--4247.org.readthedocs.build/

@miketheman
Copy link
Member Author

Definitely needs more styling, and I put it at the top of the sidebar since that made sense to me, but it might be better elsewhere.

Left a TODO - I'm not sure how/when the nodes attributes are getting cleared after PEPTitle.apply() - something else is removing anything non-classes and I wasn't able to figure it out yet.

But give it a whirl!

@nineteendo
Copy link
Contributor

The search box looks a little big to me, and it displays "Python Enhancement Proposals" instead of the page titles. But it already looks promising.

@willingc
Copy link
Contributor

@miketheman I'm not familiar with pagefind. I tried the preview site and it works well. Thank you!

@miketheman
Copy link
Member Author

Thanks gang!

Definitely needs some styling, and mobile theme integration, since that doesn't appear to work on my phone yet.

Instead of using sphinx's built-in search which has some challenges
in its implementation, as well as the integration with the customized
builder and theme, use a different approach.

Pagefind will generate fragments that can be loaded client-side
efficiently.

Refs: https://pagefind.app/
Refs: https://pypi.org/project/pagefind/

Signed-off-by: Mike Fiedler <[email protected]>
Since `title` variable is already available in the HTML, use that and
hide it from view instead of trying to muck with the nodes during
transformation.

Signed-off-by: Mike Fiedler <[email protected]>
The default inherited styles are good enough to get started, and styling
can happen at any point with customization in `style.css` instead of
trying to mash the default style to work here.

Refs: https://pagefind.app/docs/ui-usage/#customising-the-styles

Signed-off-by: Mike Fiedler <[email protected]>
@miketheman miketheman marked this pull request as ready for review August 22, 2025 20:28
@miketheman
Copy link
Member Author

Ready for a second round of review. Default styling removed, so that inline/inherited styles work "just well enough".

@nineteendo
Copy link
Contributor

The titles are now correct, but it seems the numbering resets every 10 entries.

@miketheman
Copy link
Member Author

The titles are now correct, but it seems the numbering resets every 10 entries.

Thanks for checking! Can you share a search that repeats, and maybe a screenshot of the results?

@nineteendo
Copy link
Contributor

"Style Guide for C Code":

Screenshot 2025-08-23 at 21 28 16

I also think it doesn't search in the title.

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.

Infra: Add search to the PEP index
3 participants