-
Notifications
You must be signed in to change notification settings - Fork 142
Add PageFind beta V2 (Full Text Search across Site) #2857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MoshiMoshiMochi
wants to merge
39
commits into
MarkBind:master
Choose a base branch
from
MoshiMoshiMochi:feat/pagefind-beta
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,141
−11
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
3d8dd75
Copy gerteck's pagefind implementation
MoshiMoshiMochi 86a801e
Add initial agolia styling & remove redundant code
MoshiMoshiMochi 73f10b8
Implement temporary url fix
MoshiMoshiMochi 1b15437
Add arrow key navigation support
MoshiMoshiMochi e460b03
Add auto highlight first result
MoshiMoshiMochi e3e463e
Add hover focus support
MoshiMoshiMochi 0399f44
Increase results limit to 100
MoshiMoshiMochi 4b2e373
Support pagefind.json configuration file
MoshiMoshiMochi 5e82202
Change logic of how url is fixed
MoshiMoshiMochi b63aa3d
Remove pagefind.json support & Add site.json support
MoshiMoshiMochi 2fe6080
Add glob configuration support for pagefind in site.json
MoshiMoshiMochi 9bd8b56
Add support for multiple glob patterns
MoshiMoshiMochi 50316ae
Update userguide and remove incomplete configuration options
MoshiMoshiMochi 33d3425
Update styling to be more like cards
MoshiMoshiMochi 2ba4f53
Remove pagefind configuration from site.json in docs
MoshiMoshiMochi 885abfc
Add error handling for indexSiteWithPagefind()
MoshiMoshiMochi 1f0d0b2
Resolve lint errors
MoshiMoshiMochi 0fec90a
Update tests
MoshiMoshiMochi c9c52d6
Add tests for SiteGenerationManager
MoshiMoshiMochi a083a27
Create Search.spec.js tests
MoshiMoshiMochi 261e338
Fix minor lint issue
MoshiMoshiMochi 7fc8517
Exclude pagefind generated files from file count & comparison
MoshiMoshiMochi 38895a7
Ignore pagefind directory
MoshiMoshiMochi 4d98326
Update directory to ignore
MoshiMoshiMochi cd2e74e
Code quality improvements for Search.vue
MoshiMoshiMochi 2823e88
Add validation for glob patterns
MoshiMoshiMochi cbc92eb
Allow absolute path as valid
MoshiMoshiMochi e9632a6
Merge remote-tracking branch 'upstream' into feat/pagefind-beta
MoshiMoshiMochi 7ee011a
Fix search icon svg issue
MoshiMoshiMochi 1a39671
Fix lint issue
MoshiMoshiMochi 90a27be
Resolve issues raised in Search.vue
MoshiMoshiMochi 040ae85
Update pagefindCss/Js to injected only if index succeeds
MoshiMoshiMochi 7f44ad4
Update documentation
MoshiMoshiMochi 4e27c51
Add support for windows glob pattern
MoshiMoshiMochi 11e5901
Fix typo in search.css
MoshiMoshiMochi 03983d2
Merge branch 'master' into feat/pagefind-beta
MoshiMoshiMochi d1d679d
Update docs
MoshiMoshiMochi 288c7ba
Merge remote-tracking branch 'upstream' into feat/pagefind-beta
MoshiMoshiMochi b62f4b8
Resolve merge conflicts
MoshiMoshiMochi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,112 @@ You can add a search bar component to your website to allow users to search the | |
| <include src="syntax/keywords.md" /> | ||
| <include src="syntax/indexing.md" /> | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| ## Using Pagefind (Beta) | ||
|
|
||
|
|
||
| MarkBind now supports [Pagefind](https://pagefind.app/), a static low-bandwidth search library, as a built-in feature. This provides full-text search capabilities without external services. | ||
|
|
||
| <box type="info"> | ||
| This is a <strong>beta</strong> feature and will be refined in future updates. To use it, you must have <code>enableSearch: true</code> in your <code>site.json</code> (this is the default). | ||
| </box> | ||
|
|
||
| <box type="warning"> | ||
| The Pagefind index is currently only generated during a full site build (e.g., <code>markbind build</code>). It will <strong>not</strong> repeatedly update during live reload (<code>markbind serve</code>) when you modify pages. You must restart the server (re-run <code>markbind serve</code>) or rebuild to refresh the search index. | ||
| </box> | ||
|
|
||
| To add the Pagefind search bar to your page, simply insert the following element where you want it to appear: | ||
|
|
||
| ```md | ||
| <search /> | ||
| ``` | ||
|
|
||
| The following UI will be rendered, which is provided by Pagefind: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, probably should update this comment since this new UI is not exxactly provided by PageFind but rather from your implementation 👍 |
||
|
|
||
| <search /> | ||
MoshiMoshiMochi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| <br> | ||
|
|
||
| ### Ignoring Individual Elements from Pagefind Search | ||
|
|
||
| You can exclude specific elements from the search index by adding the `data-pagefind-ignore` attribute to them: | ||
|
|
||
| ```html | ||
| <div> | ||
| <h1>This content will be in your search index.</h1> | ||
| <div data-pagefind-ignore> | ||
| This content and all its children will be excluded from search. | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| For more details, see the [Pagefind documentation on removing individual elements](https://pagefind.app/docs/indexing/#removing-individual-elements-from-the-index). | ||
|
|
||
| ### Using Pagefind Configuration | ||
|
|
||
| You can customize Pagefind's indexing behavior by adding a `pagefind` configuration in your `site.json`. This allows you to control which content is indexed and how search works. | ||
|
|
||
| #### Excluding Content from Search Index | ||
|
|
||
| You can use the `exclude_selectors` option to exclude specific elements from the search index. This is useful if you are migrating from Algolia and want to reuse your existing CSS class selectors. | ||
|
|
||
| In your `site.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "pagefind": { | ||
| "exclude_selectors": [".algolia-no-index", "[class*='algolia-no-index']"] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| This tells Pagefind to exclude any element with the `algolia-no-index` class (or containing it in a space-separated list) from the search index, similar to using `data-pagefind-ignore`. | ||
|
|
||
| #### Limiting Which Pages Are Searchable | ||
|
|
||
| You can use the `glob` option to limit which pages are indexed by Pagefind. This is useful when you want search results to only show pages from specific sections of your site. | ||
|
|
||
| In your `site.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "pagefind": { | ||
| "glob": [ | ||
| "devGuide", | ||
| "userGuide/*" | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| MarkBind supports glob patterns and will automatically append `.html` to your patterns if not specified. For example: | ||
| - `"devGuide"` becomes `"devGuide/**/*.html"` | ||
| - `"devGuide/*"` becomes `"devGuide/*.html"` | ||
| - `"**/devGuide/**"` becomes `"**/devGuide/**/*.html"` | ||
| - `"*.html"` remains `"*.html"` (no change needed) | ||
|
|
||
| Only pages matching these glob patterns will appear in search results. This can be particularly useful for: | ||
| - Multi-site setups where you want to search only specific sections | ||
| - Including only certain directories from search results | ||
|
|
||
| For more details on glob patterns, see the [Pagefind documentation](https://pagefind.app/docs/config-options/#glob). | ||
|
|
||
| <panel header="Potential Future Enhancements"> | ||
|
|
||
| Additional Pagefind configuration options may be supported in future releases: | ||
|
|
||
| - **`root_selector`**: Allows specifying a custom root element for indexing (default: `html`). Useful for sites with specific content containers. | ||
| - **`force_language`**: Forces a specific language for indexing (e.g., `"en"`, `"pt"`). Improves search accuracy for multilingual sites. | ||
|
|
||
| </panel> | ||
|
|
||
|
|
||
|
|
||
| <br> | ||
|
|
||
| ## 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. | ||
MoshiMoshiMochi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.