Implement pagefind plugin with indexing and search integration #2704
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
pagefindplugin with full indexing and search capabilities. The plugin uses the Pagefind Rust API for building search indexes and provides a TypeScript module for searching via the Pagefind JS API.Rust Backend:
buildIndex(records)- Builds a search index from provided records and writes files to$APPDATA/pagefind/getBundlePath()- Returns the path to the pagefind bundle directoryclearIndex()- Removes the pagefind index directoryTypeScript Frontend (
search.ts):pagefind.jsfrom the bundle path using Tauri's asset protocolsearch(),debouncedSearch(),getFilters(),preload()functionsbundlePathoptionUpdates since last revision
search/indextobuildIndex/getBundlePath/clearIndexIndexRecordtype for structured index entries (url, content, title)Review & Testing Checklist for Human
import(/* @vite-ignore */ pagefindJsUrl)to dynamically load pagefind.js from the app data directory. Verify this works in the Tauri webview environment.convertFileSrc()to serve files from$APPDATA/pagefind/. Test that the asset protocol correctly serves the generated index files.buildIndex(), then search using the TypeScriptsearch()function. Verify results are returned correctly.build_index()viablock_on(). This could cause issues if called from an async context.Suggested Test Plan
pnpm -F desktop tauri devbuildIndex([{ url: "/test", content: "hello world", title: "Test" }])from the frontendsearch("hello")and verify results are returnedNotes
The
pagefindcrate (v1.4.0) brings in significant transitive dependencies (actix-web, actix-files, lol_html, etc.). This is expected for the full Pagefind functionality.Link to Devin run: https://app.devin.ai/sessions/677d956546574da2b81a83f8a1e8a4c7
Requested by: yujonglee (@yujonglee)