New Gallery search for sandcastle #12755
Open
+875
−65
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.
Description
Re-implement searching for sandcastles in the Gallery using pagefind.
Pagefind is primarily targeted at indexing static html files. We need to build our own custom indexes so it can search in the JS code. I've looped this into the script that already builds the gallery list of metadata. I've also chosen to store the build output inside the gallery directory so the FE can be pointed at a single "gallery path" and load everything it needs for search and the list and assets. (Eventually we will need to support multiple galleries but this is not part of this PR)
When
pagefind
builds an index it also builds the JS module we should import for that index. This makesvite
(and TS) a bit upset because it doesn't know where the files are. We need to do a dynamic import and tell vite to ignore it to actually load thepagefind
web module. I encapsulated all this logic in theGallerySearch
component to keep it all in one place.Issue number and link
Part of #12566
Testing plan
npm run dev
in the package ornpm run build-sandcastle
andnpm start
from the project rootconvertGallery.js
script intopackages/sandcastle/scripts
and run it. This will generate all the other sandcastles and re-running the build scripts will index them all.Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change