Skip to content

Commit

Permalink
docs(algolia): add doc for highlighting utils
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Sep 9, 2020
1 parent a70f80d commit 00e2227
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/website/docs/highlightAlgoliaHit.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ const highlightedAlgoliaHit = highlightAlgoliaHit({

> `AlgoliaHit` | required
The Algolia hit to retrieve the attribute value from.

### `attribute`

> `string` | required
The attribute to retrieve the highlight value from.

### `highlightPreTag`

> `string` | defaults to `<mark>`
The HTML tag to prefix the value with.

### `highlightPostTag`

> `string` | defaults to `</mark>`
The HTML tag to suffix the value with.

### `ignoreEscape`

> `string[]` | defaults to `[]`
The characters to skip from escaping.
10 changes: 10 additions & 0 deletions packages/website/docs/reverseHighlightAlgoliaHit.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ const reverseHighlightedAlgoliaHit = reverseHighlightAlgoliaHit({

> `AlgoliaHit` | required
The Algolia hit to retrieve the attribute value from.

### `attribute`

> `string` | required
The attribute to retrieve the reverse highlight value from.

### `highlightPreTag`

> `string` | defaults to `<mark>`
The HTML tag to prefix the value with.

### `highlightPostTag`

> `string` | defaults to `</mark>`
The HTML tag to suffix the value with.

### `ignoreEscape`

> `string[]` | defaults to `[]`
The characters to skip from escaping.
53 changes: 53 additions & 0 deletions packages/website/docs/reverseSnippetAlgoliaHit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
id: reverseSnippetAlgoliaHit
---

Highlights and escapes the non-matching parts of an Algolia hit snippet.

This function can be used to display the differences of a hit match.

# Example

```js
import { reverseSnippetAlgoliaHit } from '@algolia/autocomplete-preset-algolia';

const hit = {}; // fetch an Algolia hit
const reverseSnippetedAlgoliaHit = reverseSnippetAlgoliaHit({
hit,
attribute: 'query',
});
```

# Reference

## Params

### `hit`

> `AlgoliaHit` | required
The Algolia hit to retrieve the attribute value from.

### `attribute`

> `string` | required
The attribute to retrieve the reverse snippet value from.

### `highlightPreTag`

> `string` | defaults to `<mark>`
The HTML tag to prefix the value with.

### `highlightPostTag`

> `string` | defaults to `</mark>`
The HTML tag to suffix the value with.

### `ignoreEscape`

> `string[]` | defaults to `[]`
The characters to skip from escaping.
10 changes: 10 additions & 0 deletions packages/website/docs/snippetAlgoliaHit.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ const snippetedAlgoliaHit = snippetAlgoliaHit({

> `AlgoliaHit` | required
The Algolia hit to retrieve the attribute value from.

### `attribute`

> `string` | required
The attribute to retrieve the snippet value from.

### `highlightPreTag`

> `string` | defaults to `<mark>`
The HTML tag to prefix the value with.

### `highlightPostTag`

> `string` | defaults to `</mark>`
The HTML tag to suffix the value with.

### `ignoreEscape`

> `string[]` | defaults to `[]`
The characters to skip from escaping.
1 change: 1 addition & 0 deletions packages/website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = {
'highlightAlgoliaHit',
'reverseHighlightAlgoliaHit',
'snippetAlgoliaHit',
'reverseSnippetAlgoliaHit',
'getAlgoliaHits',
'getAlgoliaResults',
],
Expand Down

0 comments on commit 00e2227

Please sign in to comment.