1
0
Fork 0

docs: document recordVersion (#1380)

This commit is contained in:
Clément Vannicatte 2022-04-26 13:12:47 +02:00 committed by GitHub
parent 9cc9801f6f
commit 1219a68b67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 5 deletions

View file

@ -179,10 +179,17 @@ const translations: DocSearchTranslations = {
> `type: ({ query: string }) => string` | **optional**
> example: ({ query }) => `https://github.com/algolia/docsearch/issues/new?title=${query}`
Function to return the URL of your documentation repository.
```js
docsearch({
// ...
getMissingResultsUrl({ query }) {
return `https://github.com/algolia/docsearch/issues/new?title=${query}`;
},
});
```
When provided, an informative message wrapped with your link will be displayed on no results searches. The default text can be changed using the [translations](#translations) property.
<div className="uil-ta-center">
@ -375,10 +382,17 @@ const translations: DocSearchTranslations = {
> `type: ({ query: string }) => string` | **optional**
> example: ({ query }) => `https://github.com/algolia/docsearch/issues/new?title=${query}`
Function to return the URL of your documentation repository.
```jsx
<DocSearch
// ...
getMissingResultsUrl={({ query }) => {
return `https://github.com/algolia/docsearch/issues/new?title=${query}`;
}}
/>
```
When provided, an informative message wrapped with your link will be displayed on no results searches. The default text can be changed using the [translations](#translations) property.
<div className="uil-ta-center">

View file

@ -203,7 +203,7 @@ This parameter allow you to boost records built from the current `pathsToMatch`.
### Reduce the number records
If you encounter the `Extractors returned too many records` error when your page outputs more than 750 records, you can use the `aggregateContent` option to reduce the number of records at the `content` level.
If you encounter the `Extractors returned too many records` error when your page outputs more than 750 records. The [`aggregateContent`](#aggregatecontent) option helps you reducing the number of records at the `content` level of the extractor.
```js
{
@ -226,6 +226,31 @@ If you encounter the `Extractors returned too many records` error when your page
},
```
### Reduce the record size
If you encounter the `Records extracted are too big` error when crawling your website, it's mostly because there was too many informations in your records, or that your page is too big. The [`recordVersion`](#recordversion) option helps you reducing the records size by removing informations that are only used with [DocSearch v2](/docs/legacy/dropdown).
```js
{
indexName: "YOUR_INDEX_NAME",
pathsToMatch: ["https://YOUR_WEBSITE_URL/api/**"],
recordExtractor: ({ $, helpers }) => {
return helpers.docsearch({
recordProps: {
lvl0: "header h1",
lvl1: "article h2",
lvl2: "article h3",
lvl3: "article h4",
lvl4: "article h5",
lvl5: "article h6",
content: "article p, article li",
},
recordVersion: "v3",
});
},
},
```
## `recordProps` API Reference
### `lvl0`
@ -278,6 +303,12 @@ Custom variables are used to [`filter your search`](/docs/DocSearch-v3#filtering
[This options](#reduce-the-number-records) groups the Algolia records created at the `content` level of the selector into a single record for its matching heading.
### `recordVersion`
> `type: 'v3' | 'v2'` | default: `v2` | **optional**
[This options](#reduce-the-record-size) remove content from the Algolia records that are only used for [DocSearch v2](/docs/legacy/dropdown). If you are using [the latest version of DocSearch](/docs/DocSearch-v3), you can [set it to `v3`](#reduce-the-record-size).
### `indexHeadings`
> `type: boolean | { from: number, to: number }` | default: `true` | **optional**