-
-
Notifications
You must be signed in to change notification settings - Fork 979
Allow passing user options to pagefind.createIndex
#3674
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
base: main
Are you sure you want to change the base?
Changes from all commits
eba93ea
1220146
24b0751
3a6c667
697254d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@astrojs/starlight': patch | ||
| --- | ||
|
|
||
| Allow passing user options to pagefind.createIndex |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -503,6 +503,7 @@ Set `pagefind` to an object to configure the Pagefind search client: | |||||||||||||||
|
|
||||||||||||||||
| - See [“Customize Pagefind's result ranking”](https://pagefind.app/docs/ranking/) in the Pagefind documentation for more details about using the `pagefind.ranking` option to control how search result ranking is calculated | ||||||||||||||||
| - See [“Searching multiple sites”](https://pagefind.app/docs/multisite/) in the Pagefind documentation for more details about using the `pagefind.mergeIndex` option to control how to search across multiple sites | ||||||||||||||||
| - See [“pagefind.createIndex”](https://pagefind.app/docs/node-api/#pagefindcreateindex) in the Pagefind documentation for more details about using the `pagefind.index` option to customize what content is indexed. | ||||||||||||||||
|
|
||||||||||||||||
| #### `PagefindOptions` | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -529,6 +530,10 @@ interface PagefindOptions { | |||||||||||||||
| termSimilarity?: number; | ||||||||||||||||
| }; | ||||||||||||||||
| }>; | ||||||||||||||||
| index?: Pick< | ||||||||||||||||
| pagefind.PagefindServiceConfig, | ||||||||||||||||
| 'rootSelector' | 'excludeSelectors' | 'forceLanguage' | ||||||||||||||||
| >; | ||||||||||||||||
|
Comment on lines
+533
to
+536
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. I’m not sure it’s useful to document this using a type from Pagefind which people can’t look up. But with the simplification, it’s probably not too bad to show the actual type? (I’m assuming it’s something like this.)
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -75,6 +75,7 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash | |||||||||||||
|
|
||||||||||||||
| <script> | ||||||||||||||
| import { pagefindUserConfig } from 'virtual:starlight/pagefind-config'; | ||||||||||||||
| const { index: _, ...pagefindClientConfig } = pagefindUserConfig; | ||||||||||||||
|
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. I think this would still end up leaking the index configuration into the client bundle. It might be better to do this here when creating the virtual module so it isn’t included at all:
And updating the virtual module type needs to be done manually too here: starlight/packages/starlight/virtual-internal.d.ts Lines 25 to 29 in 49f153d
|
||||||||||||||
|
|
||||||||||||||
| class SiteSearch extends HTMLElement { | ||||||||||||||
| constructor() { | ||||||||||||||
|
|
@@ -139,7 +140,7 @@ if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash | |||||||||||||
| // @ts-expect-error — Missing types for @pagefind/default-ui package. | ||||||||||||||
| const { PagefindUI } = await import('@pagefind/default-ui'); | ||||||||||||||
| new PagefindUI({ | ||||||||||||||
| ...pagefindUserConfig, | ||||||||||||||
| ...pagefindClientConfig, | ||||||||||||||
| element: '#starlight__search', | ||||||||||||||
| baseUrl: import.meta.env.BASE_URL, | ||||||||||||||
| bundlePath: import.meta.env.BASE_URL.replace(/\/$/, '') + '/pagefind/', | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we’ll only support
excludeSelectors, we can probably describe that here in a tiny bit of detail.