Skip to content

Conversation

@gerteck
Copy link
Member

@gerteck gerteck commented Jan 11, 2026

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:

#2568

Instead of chasing perfection, let's release a simple integration version of pagefind first.

Original Search Issue is #205

Didn't add any testcases as this is just a beta feature.

Anything you'd like to highlight/discuss:

Testing instructions:

Proposed commit message: (wrap lines at 72 characters)

Add basic PageFind Functionality with default UI


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).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds Pagefind as a beta search feature to MarkBind, providing static full-text search capabilities without requiring external services. The implementation integrates Pagefind indexing into the build process and automatically injects the necessary UI scripts and styles when enableSearch is enabled.

Changes:

  • Added pagefind npm package (v1.4.0) as a dependency
  • Integrated pagefind indexing in the site generation process after all assets are copied
  • Updated page templates to conditionally inject pagefind CSS and JavaScript resources

Reviewed changes

Copilot reviewed 118 out of 120 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/core/src/Site/index.ts Added indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.ts New file containing the pagefind UI initialization script
packages/core/src/Page/page.njk Updated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.ts Added pagefind-related properties to PageAssets interface
packages/core/package.json Added pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.js Updated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.js Updated tests to ignore generated pagefind directories
.gitignore / .eslintignore Added patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.md Added documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.html Updated expected test outputs to include pagefind scripts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1599 to +1603
const { index } = await createIndex({
keepIndexUrl: true,
verbose: true,
logfile: 'debug.log',
});
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verbose and logfile options should not be hardcoded in production code. The verbose: true and logfile: 'debug.log' configuration will create debug log files and produce excessive console output for all users. Consider either removing these options or making them conditional based on an environment variable or debug flag.

Copilot uses AI. Check for mistakes.
} else {
logger.error('Pagefind failed to create index');
}
await close();
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error handling for the close() call. If the close operation fails, the error should be caught and logged to prevent unhandled promise rejections.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +15
new window.PagefindUI({
element: container,
showSubResults: true,
showImages: false,
});
});
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error handling for the PagefindUI instantiation. If the window.PagefindUI constructor is not available (e.g., if the script fails to load), this will throw an uncaught error. Consider checking for the existence of window.PagefindUI before attempting to instantiate it.

Copilot uses AI. Check for mistakes.

## Using External Search Services

MarkBind sites can use Algolia Doc Search services easily via the Algolia plugin. Unlike the built-in search, Algolia provides full-text search. See the panel below for more info.
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states that Pagefind provides "full-text search capabilities without external services" (line 44), but then on line 71, it says "Unlike the built-in search, Algolia provides full-text search." This creates confusion about whether the built-in Pagefind feature provides full-text search or not. The messaging should be clarified for consistency.

Suggested change
MarkBind sites can use Algolia Doc Search services easily via the Algolia plugin. Unlike the built-in search, Algolia provides full-text search. See the panel below for more info.
MarkBind sites can use Algolia Doc Search services easily via the Algolia plugin. Algolia is a hosted service that also provides full-text search and advanced search features. See the panel below for more info.

Copilot uses AI. Check for mistakes.
Comment on lines +549 to +551
if (this.siteConfig.enableSearch) {
await this.indexSiteWithPagefind();
}
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pagefind indexing should be wrapped in a try-catch block or the error should be propagated properly. Currently, if indexSiteWithPagefind() throws an error, it will bypass the error handler at line 556-558 and potentially leave the build in an inconsistent state. Consider wrapping the pagefind call in try-catch to log the error and continue the build, or ensure errors are properly propagated.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jan 11, 2026

Codecov Report

❌ Patch coverage is 20.68966% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.13%. Comparing base (2400af3) to head (c23d098).

Files with missing lines Patch % Lines
packages/core/src/Site/index.ts 14.81% 19 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2771      +/-   ##
==========================================
- Coverage   62.30%   62.13%   -0.17%     
==========================================
  Files         130      131       +1     
  Lines        7184     7213      +29     
  Branches     1580     1521      -59     
==========================================
+ Hits         4476     4482       +6     
+ Misses       2644     2535     -109     
- Partials       64      196     +132     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gerteck
Copy link
Member Author

gerteck commented Jan 11, 2026

@gerteck gerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site) Jan 12, 2026
@gerteck
Copy link
Member Author

gerteck commented Jan 12, 2026

A sample for CS2103 website is here: https://changerteck.com/website-2526S1/admin/usingThisWebsite.html

image image

@damithc
Copy link
Contributor

damithc commented Jan 12, 2026

A sample for CS2103 website is here: https://changerteck.com/website-2526S1/admin/usingThisWebsite.html

This is great. Thanks for the quick turnaround, @gerteck

Next step could be to block certain paths from search results. For example, searching for 'refactoring' gives the following top three results. It's nice if we can block the first and the third and just limit to the 2nd one.

https://changerteck.com/website-2526S1/book/refactoring/index.html
https://changerteck.com/website-2526S1/se-book-adapted/chapters/refactoring.html
https://changerteck.com/website-2526S1/se-book-adapted/chapters-printable/refactoring-printable.html

Not sure if this kind of blocking can be implemented in the current stop-gap implementation or we need for the 'proper' implementation later. In the meantime, I'll test it a bit more to see if it is already good enough to go into the live site.

@gerteck
Copy link
Member Author

gerteck commented Jan 13, 2026

Not sure if this kind of blocking can be implemented in the current stop-gap implementation or we need for the 'proper' implementation later. In the meantime, I'll test it a bit more to see if it is already good enough to go into the live site.

Thinking about it, I think we can come up with a search blocking that conforms to the current interface already used (i.e. searchable: "no"), without too much issue or compromising the code maintainability.

@damithc
Copy link
Contributor

damithc commented Jan 13, 2026

Thinking about it, I think we can come up with a search blocking that conforms to the current interface already used (i.e. searchable: "no"), without too much issue or compromising the code maintainability.

Yup. It is already in the site.json (in the pages setting), but needs to propagate to the search plugin.

@damithc
Copy link
Contributor

damithc commented Jan 13, 2026

@gerteck On a related note, we currently tell Algolia to omit an element from indexing using a class algolia-no-index. I suppose at some point we can use a similar feature for our own search.

@gerteck
Copy link
Member Author

gerteck commented Jan 13, 2026

@gerteck On a related note, we currently tell Algolia to omit an element from indexing using a class algolia-no-index. I suppose at some point we can use a similar feature for our own search.

PageFind works similarly, which makes use of data-pagefind-ignore attribute. We can also customize a more convenient way to incoporate a more powerful feature if needed.

https://pagefind.app/docs/indexing/#removing-individual-elements-from-the-index

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.

2 participants