From aface238e61ca75ed8cef61b42a05b34ec53f16b Mon Sep 17 00:00:00 2001 From: Marcus Whybrow Date: Thu, 3 Oct 2024 12:34:47 +0100 Subject: [PATCH] Add doc notes for `html` `lang` re result id's For the impetus for this addition see cloudcannon/pagefind#371 --- docs/content/docs/_index.md | 4 ++++ docs/content/docs/api.md | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/content/docs/_index.md b/docs/content/docs/_index.md index 87fdf08c..5f77e724 100644 --- a/docs/content/docs/_index.md +++ b/docs/content/docs/_index.md @@ -63,3 +63,7 @@ Loading this in your browser, you should see a search input on your page. Try se The last required step is to run Pagefind after building your site on your CMS or hosting platform. If you're a CloudCannon user, add a [`.cloudcannon/postbuild`](https://cloudcannon.com/documentation/articles/extending-your-build-process-with-hooks/) file containing the npx command above (minus the `--serve` flag). For other platforms, set up an equivalent command to run after your site build — the end goal is that Pagefind will run after every build of your site before it is deployed. For many use cases, you can stop here and mark it as complete. Or, you can dive deeper into Pagefind and configure it to your liking — check out [Configuring the index](/docs/indexing/) for some next steps. + +## Notes + +> For optimal performance, ensure the `lang` attribute is set on your `html` element. See [Multilingual Search](/docs/multilingual) for more details. diff --git a/docs/content/docs/api.md b/docs/content/docs/api.md index 8436df0e..afb5a67e 100644 --- a/docs/content/docs/api.md +++ b/docs/content/docs/api.md @@ -58,7 +58,7 @@ This will return an object with the following structure: { results: [ { - id: "6fceec9", + id: "en_6fceec9", data: async function data() } ] @@ -67,6 +67,8 @@ This will return an object with the following structure: At this point you will have access to the number of search results, and a unique ID for each result. Also see [Debounced search](#debounced-search) below for an alternative API. +> Note that the prefix `en` in `en_6fceec9` matches the `lang` attribute of your `html` element. If `lang` is not set, the prefix defaults to `unknown`. See [Multilingual Search](/docs/multilingual) for more details. + ## Loading a result To reduce bandwidth usage, the data for each result (e.g. URL & title) must be loaded independently.