Skip to content

Add search functionality using Pagefind #1935

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 80 commits into
base: main
Choose a base branch
from

Conversation

doup
Copy link
Contributor

@doup doup commented Feb 26, 2025

This PR adds search functionality using Pagefind Rust based library. The search index built by Pagefind is generated based on the final website HTML files. Because of that I had to change the deploy action; now building with Zola, creating the search index and deploying are different steps.

For reviewers

You'll need to generate the Pagefind index, follow these instructions:
https://github.com/doup/bevy-website/tree/pagefind-search?tab=readme-ov-file#local-development

Closes #1204.

image

image image image image

Deploy Settings

I had to use these settings to deploy with the new modified deploy action. Fine-grained PAT Permissions:

image

Also, had to add my branch pagefind-search to the repo Settings > Environments > Configure "github-pages" > Deployment branches and tags. So, main probably needs to be there.

github-merge-queue bot pushed a commit to bevyengine/bevy that referenced this pull request Mar 18, 2025
…kdown (#18191)

# Objective

Separate example explanation (file docblock) and the code so they can be
layout differently in the website and we can give a higher importance to
the explanation on the [website search
tool](bevyengine/bevy-website#1935). This would
also allow us to improve the examples so they become even more like a
cookbook.

## Solution

Update the `example-showcase` tool to extract the example file docblock
and write it as the example markdown content. This allows us to access
the explanation via `page.content` in Zola.

## Testing

I've checked that the output is correct after running the tool and it
doesn't throw any error. I've also validated that the approach will work
on the website.

## Showcase

This is a quick and dirty example of what we could do in the web
examples after the change. When we implement the real thing we can put
the explanation on a sidebar or explore other layout options.

<img width="1362" alt="image"
src="https://github.com/user-attachments/assets/6738542e-31c3-41cd-972a-7fa2e942e85d"
/>
github-merge-queue bot pushed a commit to bevyengine/bevy that referenced this pull request Mar 19, 2025
…kdown (#18191)

# Objective

Separate example explanation (file docblock) and the code so they can be
layout differently in the website and we can give a higher importance to
the explanation on the [website search
tool](bevyengine/bevy-website#1935). This would
also allow us to improve the examples so they become even more like a
cookbook.

## Solution

Update the `example-showcase` tool to extract the example file docblock
and write it as the example markdown content. This allows us to access
the explanation via `page.content` in Zola.

## Testing

I've checked that the output is correct after running the tool and it
doesn't throw any error. I've also validated that the approach will work
on the website.

## Showcase

This is a quick and dirty example of what we could do in the web
examples after the change. When we implement the real thing we can put
the explanation on a sidebar or explore other layout options.

<img width="1362" alt="image"
src="https://github.com/user-attachments/assets/6738542e-31c3-41cd-972a-7fa2e942e85d"
/>
mockersf pushed a commit to bevyengine/bevy that referenced this pull request Mar 19, 2025
…kdown (#18191)

# Objective

Separate example explanation (file docblock) and the code so they can be
layout differently in the website and we can give a higher importance to
the explanation on the [website search
tool](bevyengine/bevy-website#1935). This would
also allow us to improve the examples so they become even more like a
cookbook.

## Solution

Update the `example-showcase` tool to extract the example file docblock
and write it as the example markdown content. This allows us to access
the explanation via `page.content` in Zola.

## Testing

I've checked that the output is correct after running the tool and it
doesn't throw any error. I've also validated that the approach will work
on the website.

## Showcase

This is a quick and dirty example of what we could do in the web
examples after the change. When we implement the real thing we can put
the explanation on a sidebar or explore other layout options.

<img width="1362" alt="image"
src="https://github.com/user-attachments/assets/6738542e-31c3-41cd-972a-7fa2e942e85d"
/>
@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Meta C-Webdev S-Waiting-On-Author labels Mar 20, 2025
@doup doup marked this pull request as ready for review April 2, 2025 16:25
@BenjaminBrienen
Copy link
Contributor

search button doesn't work for me

Screen.Recording.2025-05-16.131636.mp4
PS C:\Users\BenjaminBrienen\source\bevy-website> zola serve
Building site...
Warning: Highlight language shell not found in learn/migration-guides/0.11-to-0.12.md
Warning: Highlight language ron not found
Warning: Highlight language shell not found in learn/migration-guides/0.14-to-0.15.md
Warning: Highlight language shell not found in learn/migration-guides/0.14-to-0.15.md
Warning: Highlight language shell not found in learn/migration-guides/0.14-to-0.15.md
Warning: Highlight language shell not found in learn/migration-guides/0.14-to-0.15.md
Warning: Highlight language ron not found in learn/migration-guides/0.14-to-0.15.md
Warning: Highlight language ron not found in learn/migration-guides/0.14-to-0.15.md
Checking all internal links with anchors.
> Successfully checked 32 internal link(s) with anchors.
-> Creating 123 pages (0 orphan) and 35 sections
Done in 3.8s.

Listening for changes in \\?\C:\Users\BenjaminBrienen\source\bevy-website\{config.toml,content,sass,static,templates}
Press Ctrl+C to stop

Web server is available at http://127.0.0.1:1111 (bound to 127.0.0.1:1111)

@doup
Copy link
Contributor Author

doup commented May 20, 2025

@BenjaminBrienen have you generated the Pagefind index? You'll need to follow these steps:
https://github.com/doup/bevy-website/tree/pagefind-search?tab=readme-ov-file#local-development

Sorry, my bad, I forgot to mention it… 😅

@cart cart moved this to Respond (With Priority) in @cart's attention May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Meta C-Feature A new feature, making something new possible C-Webdev D-Complex S-Needs-Review
Projects
Status: Respond (With Priority)
Development

Successfully merging this pull request may close these issues.

5 participants