Skip to content

Add PageFind beta (Full Text Search across Site) - #2771

Closed
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind
Closed

Add PageFind beta (Full Text Search across Site)#2771
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind

Conversation

@gerteck

@gerteckgerteck commented Jan 11, 2026

Copy link
Copy Markdown
Member

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/Site/index.tsAdded indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.tsNew file containing the pagefind UI initialization script
packages/core/src/Page/page.njkUpdated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.tsAdded pagefind-related properties to PageAssets interface
packages/core/package.jsonAdded pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.jsUpdated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.jsUpdated tests to ignore generated pagefind directories
.gitignore / .eslintignoreAdded patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.mdAdded documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.htmlUpdated expected test outputs to include pagefind scripts

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

Comment threadpackages/core/src/Site/index.ts
} else {
logger.error('Pagefind failed to create index');
}
await close();

CopilotAIJan 11, 2026

Copy link

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,
});
});

CopilotAIJan 11, 2026

Copy link

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.

CopilotAIJan 11, 2026

Copy link

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();
}

CopilotAIJan 11, 2026

Copy link

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

codecovBot commented Jan 11, 2026

Copy link
Copy Markdown

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).
⚠️ Report is 123 commits behind head on master.

Files with missing linesPatch %Lines
packages/core/src/Site/index.ts14.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
Copy Markdown
MemberAuthor

@gerteckgerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site)Jan 12, 2026
@gerteck

gerteck commented Jan 12, 2026

Copy link
Copy Markdown
MemberAuthor

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

imageimage

@damithc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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
Copy Markdown
MemberAuthor

@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

@gerteck
gerteck marked this pull request as draft January 27, 2026 08:34
@gerteck

Copy link
Copy Markdown
MemberAuthor

@gerteck

Copy link
Copy Markdown
MemberAuthor

Closed by #2857, PageFind is officially integrated into MarkBind (as a beta feature, with structured planned improvements) 🎉

@gerteckgerteck closed this Mar 27, 2026
Sign up for freeto 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.

3 participants

@gerteck@damithc
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Add PageFind beta (Full Text Search across Site) by gerteck · Pull Request #2771 · MarkBind/markbind · GitHub
Skip to content

Add PageFind beta (Full Text Search across Site) - #2771

Closed
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind
Closed

Add PageFind beta (Full Text Search across Site)#2771
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind

Conversation

@gerteck

@gerteckgerteck commented Jan 11, 2026

Copy link
Copy Markdown
Member

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/Site/index.tsAdded indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.tsNew file containing the pagefind UI initialization script
packages/core/src/Page/page.njkUpdated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.tsAdded pagefind-related properties to PageAssets interface
packages/core/package.jsonAdded pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.jsUpdated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.jsUpdated tests to ignore generated pagefind directories
.gitignore / .eslintignoreAdded patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.mdAdded documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.htmlUpdated expected test outputs to include pagefind scripts

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

Comment threadpackages/core/src/Site/index.ts
} else {
logger.error('Pagefind failed to create index');
}
await close();

CopilotAIJan 11, 2026

Copy link

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,
});
});

CopilotAIJan 11, 2026

Copy link

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.

CopilotAIJan 11, 2026

Copy link

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();
}

CopilotAIJan 11, 2026

Copy link

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

codecovBot commented Jan 11, 2026

Copy link
Copy Markdown

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).
⚠️ Report is 123 commits behind head on master.

Files with missing linesPatch %Lines
packages/core/src/Site/index.ts14.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
Copy Markdown
MemberAuthor

@gerteckgerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site)Jan 12, 2026
@gerteck

gerteck commented Jan 12, 2026

Copy link
Copy Markdown
MemberAuthor

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

imageimage

@damithc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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
Copy Markdown
MemberAuthor

@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

@gerteck
gerteck marked this pull request as draft January 27, 2026 08:34
@gerteck

Copy link
Copy Markdown
MemberAuthor

@gerteck

Copy link
Copy Markdown
MemberAuthor

Closed by #2857, PageFind is officially integrated into MarkBind (as a beta feature, with structured planned improvements) 🎉

@gerteckgerteck closed this Mar 27, 2026
Sign up for freeto 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.

3 participants

@gerteck@damithc
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add PageFind beta (Full Text Search across Site) by gerteck · Pull Request #2771 · MarkBind/markbind · GitHub
Skip to content

Add PageFind beta (Full Text Search across Site) - #2771

Closed
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind
Closed

Add PageFind beta (Full Text Search across Site)#2771
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind

Conversation

@gerteck

@gerteckgerteck commented Jan 11, 2026

Copy link
Copy Markdown
Member

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/Site/index.tsAdded indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.tsNew file containing the pagefind UI initialization script
packages/core/src/Page/page.njkUpdated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.tsAdded pagefind-related properties to PageAssets interface
packages/core/package.jsonAdded pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.jsUpdated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.jsUpdated tests to ignore generated pagefind directories
.gitignore / .eslintignoreAdded patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.mdAdded documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.htmlUpdated expected test outputs to include pagefind scripts

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

Comment threadpackages/core/src/Site/index.ts
} else {
logger.error('Pagefind failed to create index');
}
await close();

CopilotAIJan 11, 2026

Copy link

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,
});
});

CopilotAIJan 11, 2026

Copy link

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.

CopilotAIJan 11, 2026

Copy link

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();
}

CopilotAIJan 11, 2026

Copy link

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

codecovBot commented Jan 11, 2026

Copy link
Copy Markdown

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).
⚠️ Report is 123 commits behind head on master.

Files with missing linesPatch %Lines
packages/core/src/Site/index.ts14.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
Copy Markdown
MemberAuthor

@gerteckgerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site)Jan 12, 2026
@gerteck

gerteck commented Jan 12, 2026

Copy link
Copy Markdown
MemberAuthor

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

imageimage

@damithc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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
Copy Markdown
MemberAuthor

@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

@gerteck
gerteck marked this pull request as draft January 27, 2026 08:34
@gerteck

Copy link
Copy Markdown
MemberAuthor

@gerteck

Copy link
Copy Markdown
MemberAuthor

Closed by #2857, PageFind is officially integrated into MarkBind (as a beta feature, with structured planned improvements) 🎉

@gerteckgerteck closed this Mar 27, 2026
Sign up for freeto 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.

3 participants

@gerteck@damithc
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add PageFind beta (Full Text Search across Site) by gerteck · Pull Request #2771 · MarkBind/markbind · GitHub
Skip to content

Add PageFind beta (Full Text Search across Site) - #2771

Closed
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind
Closed

Add PageFind beta (Full Text Search across Site)#2771
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind

Conversation

@gerteck

@gerteckgerteck commented Jan 11, 2026

Copy link
Copy Markdown
Member

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/Site/index.tsAdded indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.tsNew file containing the pagefind UI initialization script
packages/core/src/Page/page.njkUpdated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.tsAdded pagefind-related properties to PageAssets interface
packages/core/package.jsonAdded pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.jsUpdated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.jsUpdated tests to ignore generated pagefind directories
.gitignore / .eslintignoreAdded patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.mdAdded documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.htmlUpdated expected test outputs to include pagefind scripts

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

Comment threadpackages/core/src/Site/index.ts
} else {
logger.error('Pagefind failed to create index');
}
await close();

CopilotAIJan 11, 2026

Copy link

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,
});
});

CopilotAIJan 11, 2026

Copy link

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.

CopilotAIJan 11, 2026

Copy link

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();
}

CopilotAIJan 11, 2026

Copy link

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

codecovBot commented Jan 11, 2026

Copy link
Copy Markdown

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).
⚠️ Report is 123 commits behind head on master.

Files with missing linesPatch %Lines
packages/core/src/Site/index.ts14.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
Copy Markdown
MemberAuthor

@gerteckgerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site)Jan 12, 2026
@gerteck

gerteck commented Jan 12, 2026

Copy link
Copy Markdown
MemberAuthor

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

imageimage

@damithc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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
Copy Markdown
MemberAuthor

@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

@gerteck
gerteck marked this pull request as draft January 27, 2026 08:34
@gerteck

Copy link
Copy Markdown
MemberAuthor

@gerteck

Copy link
Copy Markdown
MemberAuthor

Closed by #2857, PageFind is officially integrated into MarkBind (as a beta feature, with structured planned improvements) 🎉

@gerteckgerteck closed this Mar 27, 2026
Sign up for freeto 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.

3 participants

@gerteck@damithc
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Add PageFind beta (Full Text Search across Site) by gerteck · Pull Request #2771 · MarkBind/markbind · GitHub
Skip to content

Add PageFind beta (Full Text Search across Site) - #2771

Closed
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind
Closed

Add PageFind beta (Full Text Search across Site)#2771
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind

Conversation

@gerteck

@gerteckgerteck commented Jan 11, 2026

Copy link
Copy Markdown
Member

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/Site/index.tsAdded indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.tsNew file containing the pagefind UI initialization script
packages/core/src/Page/page.njkUpdated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.tsAdded pagefind-related properties to PageAssets interface
packages/core/package.jsonAdded pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.jsUpdated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.jsUpdated tests to ignore generated pagefind directories
.gitignore / .eslintignoreAdded patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.mdAdded documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.htmlUpdated expected test outputs to include pagefind scripts

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

Comment threadpackages/core/src/Site/index.ts
} else {
logger.error('Pagefind failed to create index');
}
await close();

CopilotAIJan 11, 2026

Copy link

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,
});
});

CopilotAIJan 11, 2026

Copy link

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.

CopilotAIJan 11, 2026

Copy link

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();
}

CopilotAIJan 11, 2026

Copy link

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

codecovBot commented Jan 11, 2026

Copy link
Copy Markdown

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).
⚠️ Report is 123 commits behind head on master.

Files with missing linesPatch %Lines
packages/core/src/Site/index.ts14.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
Copy Markdown
MemberAuthor

@gerteckgerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site)Jan 12, 2026
@gerteck

gerteck commented Jan 12, 2026

Copy link
Copy Markdown
MemberAuthor

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

imageimage

@damithc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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
Copy Markdown
MemberAuthor

@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

@gerteck
gerteck marked this pull request as draft January 27, 2026 08:34
@gerteck

Copy link
Copy Markdown
MemberAuthor

@gerteck

Copy link
Copy Markdown
MemberAuthor

Closed by #2857, PageFind is officially integrated into MarkBind (as a beta feature, with structured planned improvements) 🎉

@gerteckgerteck closed this Mar 27, 2026
Sign up for freeto 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.

3 participants

@gerteck@damithc
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add PageFind beta (Full Text Search across Site) by gerteck · Pull Request #2771 · MarkBind/markbind · GitHub
Skip to content

Add PageFind beta (Full Text Search across Site) - #2771

Closed
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind
Closed

Add PageFind beta (Full Text Search across Site)#2771
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind

Conversation

@gerteck

@gerteckgerteck commented Jan 11, 2026

Copy link
Copy Markdown
Member

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/Site/index.tsAdded indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.tsNew file containing the pagefind UI initialization script
packages/core/src/Page/page.njkUpdated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.tsAdded pagefind-related properties to PageAssets interface
packages/core/package.jsonAdded pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.jsUpdated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.jsUpdated tests to ignore generated pagefind directories
.gitignore / .eslintignoreAdded patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.mdAdded documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.htmlUpdated expected test outputs to include pagefind scripts

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

Comment threadpackages/core/src/Site/index.ts
} else {
logger.error('Pagefind failed to create index');
}
await close();

CopilotAIJan 11, 2026

Copy link

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,
});
});

CopilotAIJan 11, 2026

Copy link

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.

CopilotAIJan 11, 2026

Copy link

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();
}

CopilotAIJan 11, 2026

Copy link

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

codecovBot commented Jan 11, 2026

Copy link
Copy Markdown

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).
⚠️ Report is 123 commits behind head on master.

Files with missing linesPatch %Lines
packages/core/src/Site/index.ts14.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
Copy Markdown
MemberAuthor

@gerteckgerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site)Jan 12, 2026
@gerteck

gerteck commented Jan 12, 2026

Copy link
Copy Markdown
MemberAuthor

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

imageimage

@damithc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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
Copy Markdown
MemberAuthor

@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

@gerteck
gerteck marked this pull request as draft January 27, 2026 08:34
@gerteck

Copy link
Copy Markdown
MemberAuthor

@gerteck

Copy link
Copy Markdown
MemberAuthor

Closed by #2857, PageFind is officially integrated into MarkBind (as a beta feature, with structured planned improvements) 🎉

@gerteckgerteck closed this Mar 27, 2026
Sign up for freeto 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.

3 participants

@gerteck@damithc
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add PageFind beta (Full Text Search across Site) by gerteck · Pull Request #2771 · MarkBind/markbind · GitHub
Skip to content

Add PageFind beta (Full Text Search across Site) - #2771

Closed
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind
Closed

Add PageFind beta (Full Text Search across Site)#2771
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind

Conversation

@gerteck

@gerteckgerteck commented Jan 11, 2026

Copy link
Copy Markdown
Member

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/Site/index.tsAdded indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.tsNew file containing the pagefind UI initialization script
packages/core/src/Page/page.njkUpdated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.tsAdded pagefind-related properties to PageAssets interface
packages/core/package.jsonAdded pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.jsUpdated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.jsUpdated tests to ignore generated pagefind directories
.gitignore / .eslintignoreAdded patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.mdAdded documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.htmlUpdated expected test outputs to include pagefind scripts

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

Comment threadpackages/core/src/Site/index.ts
} else {
logger.error('Pagefind failed to create index');
}
await close();

CopilotAIJan 11, 2026

Copy link

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,
});
});

CopilotAIJan 11, 2026

Copy link

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.

CopilotAIJan 11, 2026

Copy link

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();
}

CopilotAIJan 11, 2026

Copy link

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

codecovBot commented Jan 11, 2026

Copy link
Copy Markdown

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).
⚠️ Report is 123 commits behind head on master.

Files with missing linesPatch %Lines
packages/core/src/Site/index.ts14.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
Copy Markdown
MemberAuthor

@gerteckgerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site)Jan 12, 2026
@gerteck

gerteck commented Jan 12, 2026

Copy link
Copy Markdown
MemberAuthor

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

imageimage

@damithc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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
Copy Markdown
MemberAuthor

@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

@gerteck
gerteck marked this pull request as draft January 27, 2026 08:34
@gerteck

Copy link
Copy Markdown
MemberAuthor

@gerteck

Copy link
Copy Markdown
MemberAuthor

Closed by #2857, PageFind is officially integrated into MarkBind (as a beta feature, with structured planned improvements) 🎉

@gerteckgerteck closed this Mar 27, 2026
Sign up for freeto 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.

3 participants

@gerteck@damithc
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Add PageFind beta (Full Text Search across Site) by gerteck · Pull Request #2771 · MarkBind/markbind · GitHub
Skip to content

Add PageFind beta (Full Text Search across Site) - #2771

Closed
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind
Closed

Add PageFind beta (Full Text Search across Site)#2771
gerteck wants to merge 5 commits into
MarkBind:masterfrom
gerteck:feature/pagefind

Conversation

@gerteck

@gerteckgerteck commented Jan 11, 2026

Copy link
Copy Markdown
Member

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/Site/index.tsAdded indexSiteWithPagefind() method and integrated it into the build process
packages/core/src/Page/pagefindScript.tsNew file containing the pagefind UI initialization script
packages/core/src/Page/page.njkUpdated template to inject pagefind CSS/JS when enabled
packages/core/src/Page/PageConfig.tsAdded pagefind-related properties to PageAssets interface
packages/core/package.jsonAdded pagefind v1.4.0 dependency
packages/cli/test/functional/testUtil/compare.jsUpdated comparison utility to ignore pagefind directories
packages/cli/test/functional/test.jsUpdated tests to ignore generated pagefind directories
.gitignore / .eslintignoreAdded patterns to ignore pagefind-generated files
docs/userGuide/makingTheSiteSearchable.mdAdded documentation for the new pagefind beta feature
packages/cli/test/functional//expected//*.htmlUpdated expected test outputs to include pagefind scripts

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

Comment threadpackages/core/src/Site/index.ts
} else {
logger.error('Pagefind failed to create index');
}
await close();

CopilotAIJan 11, 2026

Copy link

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,
});
});

CopilotAIJan 11, 2026

Copy link

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.

CopilotAIJan 11, 2026

Copy link

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();
}

CopilotAIJan 11, 2026

Copy link

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

codecovBot commented Jan 11, 2026

Copy link
Copy Markdown

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).
⚠️ Report is 123 commits behind head on master.

Files with missing linesPatch %Lines
packages/core/src/Site/index.ts14.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
Copy Markdown
MemberAuthor

@gerteckgerteck changed the title Add PageFind beta Add PageFind beta (Full Text Search across Site)Jan 12, 2026
@gerteck

gerteck commented Jan 12, 2026

Copy link
Copy Markdown
MemberAuthor

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

imageimage

@damithc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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
Copy Markdown
MemberAuthor

@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

@gerteck
gerteck marked this pull request as draft January 27, 2026 08:34
@gerteck

Copy link
Copy Markdown
MemberAuthor

@gerteck

Copy link
Copy Markdown
MemberAuthor

Closed by #2857, PageFind is officially integrated into MarkBind (as a beta feature, with structured planned improvements) 🎉

@gerteckgerteck closed this Mar 27, 2026
Sign up for freeto 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.

3 participants

@gerteck@damithc