Skip to content

Add PageFind beta V2 (Full Text Search across Site)#2857

Draft
MoshiMoshiMochi wants to merge 22 commits intoMarkBind:masterfrom
MoshiMoshiMochi:feat/pagefind-beta
Draft

Add PageFind beta V2 (Full Text Search across Site)#2857
MoshiMoshiMochi wants to merge 22 commits intoMarkBind:masterfrom
MoshiMoshiMochi:feat/pagefind-beta

Conversation

@MoshiMoshiMochi
Copy link
Contributor

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Overview of changes:

Initial version of pagefind (based on #2771)

Original Search Issue is #205

No test cases yet.

Anything you'd like to highlight/discuss:

  1. Created a new Search.vue component <search /> that renders the pagefind search modal.
    • The CSS of which definitely isn't a finish product.
    • Additionally we could consider updating how we present the data.
Heres how the modal currently looks vs Algolia's (CS2103 site)

Current implementation of pagefind.
image

Algolia's styling on CS2103 website
image

From the 2 images above, I believe that Algolia's styling is notably more structured in how it represents the search results and subresults, notably on how they group the search results.

The blog we used as reference for the styling formats the pagefindresults by processing the search results. More information on how to access the specific search results information can be found here.

  1. Added pagefind configuration options within site.json to enable more flexible filtering options. Users can declare
    • exclude_selectors option to exclude specific elements from being searchable.
    • glob option to limit which pages are indexed by Pagefind.
{
  "pagefind": {
    "exclude_selectors": [".algolia-no-index", "[class*='algolia-no-index']"]
    "glob": ["**/devGuide/**", "**/userGuide/**"]
  }
}
  • from the example above,
    • exclude_selectors: tells Pagefind to exclude any element with the algolia-no-index class from the searchable results. It works the same way as declaring data-pagefind-ignore.
    • glob: Pagefind will only index pages that are found inside devGuide and userGuide directories (including subdirectories).

All in all, theres still a lot more things we can do to improve this pagefind feature (like page weighting, ranking, sorting etc). But this is all I've managed to conjure up thus far.

Let me know what yall think of these updates to the pagefind feature (there might be better ways to filter pages, this is just from my interpretation when reading through the pagefind docs). Let me know if I missed out on anything in particular or should be focusing my efforts more towards.

  • Definitely going to spend more time working on the styling. But I think if we're gonna process and present our data differently from the base Pagefind UI, then we should probably work on those at the same time since they are intrinsically linked.
  • Also needa write testcases 😔. Not looking forward to that 😢

Testing instructions:

Proposed commit message: (wrap lines at 72 characters)

Add base Pagefind with updated UI & extra filtering functionalities


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Reviewer checklist:

Indicate the SEMVER impact of the PR:

  • Major (when you make incompatible API changes)
  • Minor (when you add functionality in a backward compatible manner)
  • Patch (when you make backward compatible bug fixes)

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.

Breaking change release note preparation (if applicable):

  • To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

This added support for configuring Pagefind search indexing via
site.json is aimed towards allowing users to declare glob patterns to
customize what pages in which directory should be indexed by pagefind.
Initially, I felt that including the root_selector option and
force_language option would be useful for pagefind configuration
options. But perhaps for now it isn't the most pressing issue so I'm
going to exlcude it from the current implementation of pagefind.
This helps resolve an issue with generate() test case within
Site.functional.test.ts. Namely, because Jest's cannot intercept
eval('import("pagefind")') runtime dynamic import used by pagefind.

Hence, for now at least, the error handling would catch this error and
allow the site generation to continue normally.
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.

1 participant